11module Buff
22 class Client
33 module Update
4-
5- # Updates via Get
6- # /updates/:id
7- # /profiles/:id/updates/pending
8- # /profiles/:id/updates/sent
9- # /updates/:id/interactions
10- #
114 def update_by_id ( id , options = { } )
125 check_id ( id )
136 response = get ( "/updates/#{ id } .json" )
147 Buff ::Update . new ( response )
158 end
169
17-
1810 def updates_by_profile_id ( id , options = { } )
1911 optional_params = [ :page , :count , :since , :utc ]
2012 status = options . fetch ( :status ) do
2113 raise Buff ::MissingStatus , "Include :pending or :sent in args"
2214 end
2315 options . delete ( :status )
24- response = get ( "/profiles/#{ id } /updates/#{ status . to_s } .json" , { query : options } )
16+ response = get ( "/profiles/#{ id } /updates/#{ status . to_s } .json" , options )
2517 updates = response [ 'updates' ] . map { |r | Buff ::Update . new ( r ) }
2618 Buff ::Updates . new (
2719 { total : response [ 'total' ] , updates : updates } )
2820 end
2921
3022 def interactions_by_update_id ( id , options = { } )
3123 optional_params = [ :page , :count , :event ]
32- response = get ( "/updates/#{ id } /interactions.json" , { query : options } )
24+ response = get ( "/updates/#{ id } /interactions.json" , options )
3325 interactions = response [ 'interactions' ] . map { |r | Buff ::Interaction . new ( r ) }
3426 Buff ::Interactions . new (
3527 { total : response [ 'total' ] , interactions : interactions }
3628 )
3729 end
3830
39- # Updates via post
40- #POST
41- # /profiles/:id/updates/reorder
42- # /profiles/:id/updates/shuffle
43- # /updates/create
44- # /updates/:id/update
45- # /updates/:id/share
46- # /updates/:id/destroy
47-
4831 def reorder_updates ( profile_id , options = { } )
4932 # order, optional: offset, utc
5033 order = options . fetch ( :order ) { raise ArgumentError }
51- response = faraday_post ( "/profiles/#{ profile_id } /updates/reorder.json" , options )
34+ response = post ( "/profiles/#{ profile_id } /updates/reorder.json" , options )
5235 end
5336
5437 def shuffle_updates ( profile_id , options = { } )
5538 # optional count, utc
56- response = faraday_post ( "/profiles/#{ profile_id } /updates/shuffle.json" , options )
39+ response = post ( "/profiles/#{ profile_id } /updates/shuffle.json" , options )
5740 end
5841
5942 #TODO
@@ -73,23 +56,23 @@ def create_update(options={})
7356 # description: "That example page"
7457 # }
7558 # }
76- response = faraday_post ( "/updates/create.json" , options )
59+ response = post ( "/updates/create.json" , options )
7760 Hashie ::Mash . new ( JSON . parse response . body )
7861 end
7962
8063 def modify_update_text ( update_id , options = { } )
8164 # text, (now, media, utc)
8265 options . fetch ( :text ) { raise ArgumentError }
83- response = faraday_post ( "/updates/#{ update_id } /update.json" , options )
66+ response = post ( "/updates/#{ update_id } /update.json" , options )
8467 Hashie ::Mash . new ( JSON . parse response . body )
8568 end
8669
8770 def share_update ( update_id , options = { } )
88- response = faraday_post ( "/updates/#{ update_id } /share.json" , options )
71+ response = post ( "/updates/#{ update_id } /share.json" , options )
8972 end
9073
9174 def destroy_update ( update_id , options = { } )
92- response = faraday_post ( "/updates/#{ update_id } /destroy.json" , options )
75+ response = post ( "/updates/#{ update_id } /destroy.json" , options )
9376 end
9477
9578 def check_id ( id )
0 commit comments