instagram_geo 0.8.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,59 @@
1
+ module Instagram
2
+ class Client
3
+ # Defines methods related to media items
4
+ module Locations
5
+ # Returns extended information of a given Instagram location
6
+ #
7
+ # @overload location(id)
8
+ # @param location [Integer] An Instagram location ID
9
+ # @return [Hashie::Mash] The requested location.
10
+ # @example Return extended information for the Instagram office
11
+ # Instagram.location(514276)
12
+ # @format :json
13
+ # @authenticated false
14
+ # @rate_limited true
15
+ # @see TODO:docs url
16
+ def location(id, *args)
17
+ response = get("locations/#{id}")
18
+ response["data"]
19
+ end
20
+
21
+ # Returns a list of recent media items for a given Instagram location
22
+ #
23
+ # @overload location_recent_media(id, options={})
24
+ # @param user [Integer] An Instagram location ID.
25
+ # @param options [Hash] A customizable set of options.
26
+ # @option options [Integer] :max_id (nil) Returns results with an ID less than (that is, older than) or equal to the specified ID.
27
+ # @option options [Integer] :count (nil) Limits the number of results returned per page.
28
+ # @return [Hashie::Mash]
29
+ # @example Return a list of the most recent media items taken at the Instagram office
30
+ # Instagram.location_recent_media(514276)
31
+ # @see TODO:docs url
32
+ # @format :json
33
+ # @authenticated false
34
+ # @rate_limited true
35
+ def location_recent_media(id, *args)
36
+ options = args.last.is_a?(Hash) ? args.pop : {}
37
+ response = get("locations/#{id}/media/recent", options)
38
+ response
39
+ end
40
+
41
+ # Returns Instagram locations within proximity of given lat,lng
42
+ #
43
+ # @param lat [String] A given latitude in decimal format
44
+ # @param lng [String] A given longitude in decimal format
45
+ # @option options [Integer] :count The number of media items to retrieve.
46
+ # @return [Array]
47
+ # @example Return locations around 37.7808851, -122.3948632 (164 S Park, SF, CA USA)
48
+ # Instagram.location_search("37.7808851", "-122.3948632")
49
+ # @see TODO:doc url
50
+ # @format :json
51
+ # @authenticated false
52
+ # @rate_limited true
53
+ def location_search(lat, lng, options={})
54
+ response = get('locations/search', options.merge(:lat => lat, :lng => lng))
55
+ response["data"]
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,63 @@
1
+ module Instagram
2
+ class Client
3
+ # Defines methods related to media items
4
+ module Media
5
+ # Returns extended information of a given media item
6
+ #
7
+ # @overload media_item(id)
8
+ # @param user [Integer] An Instagram media item ID
9
+ # @return [Hashie::Mash] The requested media item.
10
+ # @example Return extended information for media item 1234
11
+ # Instagram.media_item(1324)
12
+ # @format :json
13
+ # @authenticated false unless requesting media from a protected user
14
+ #
15
+ # If getting this data of a protected user, you must authenticate (and be allowed to see that user).
16
+ # @rate_limited true
17
+ # @see TODO:docs url
18
+ def media_item(*args)
19
+ id = args.first || 'self'
20
+ response = get("media/#{id}")
21
+ response["data"]
22
+ end
23
+
24
+ # Returns a list of the overall most popular media
25
+ #
26
+ # @overload media_popular(options={})
27
+ # @param options [Hash] A customizable set of options.
28
+ # @return [Hashie::Mash]
29
+ # @example Returns a list of the overall most popular media
30
+ # Instagram.media_popular
31
+ # @see TODO:docs url
32
+ # @format :json
33
+ # @authenticated false unless requesting it from a protected user
34
+ #
35
+ # If getting this data of a protected user, you must authenticate (and be allowed to see that user).
36
+ # @rate_limited true
37
+ def media_popular(*args)
38
+ options = args.last.is_a?(Hash) ? args.pop : {}
39
+ id = args.first || "self"
40
+ response = get("media/popular", options)
41
+ response["data"]
42
+ end
43
+
44
+ # Returns media items within proximity of given lat,lng
45
+ #
46
+ # @param lat [String] A given latitude in decimal format
47
+ # @param lng [String] A given longitude in decimal format
48
+ # @param options [Hash] A customizable set of options.
49
+ # @option options [Integer] :count The number of media items to retrieve.
50
+ # @return [Array]
51
+ # @example Return media around 37.7808851, -122.3948632 (164 S Park, SF, CA USA)
52
+ # Instagram.media_search("37.7808851", "-122.3948632")
53
+ # @see TODO:doc url
54
+ # @format :json
55
+ # @authenticated false
56
+ # @rate_limited true
57
+ def media_search(lat, lng, min_timestamp, max_timestamp, distance, count, options={})
58
+ response = get('media/search', options.merge(:lat => lat, :lng => lng, :min_timestamp => min_timestamp, :max_timestamp => max_timestamp, :distance => distance, :count => count))
59
+ response
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,158 @@
1
+ require 'openssl'
2
+ require 'multi_json'
3
+
4
+ module Instagram
5
+ class Client
6
+ # Defines methods related to real-time
7
+ module Subscriptions
8
+ # Returns a list of active real-time subscriptions
9
+ #
10
+ # @overload subscriptions(options={})
11
+ # @return [Hashie::Mash] The list of subscriptions.
12
+ # @example Returns a list of subscriptions for the authenticated application
13
+ # Instagram.subscriptions
14
+ # @format :json
15
+ # @authenticated true
16
+ #
17
+ # Requires client_secret to be set on the client or passed in options
18
+ # @rate_limited true
19
+ # @see https://api.instagram.com/developer/realtime/
20
+ def subscriptions(options={})
21
+ response = get("subscriptions", options.merge(:client_secret => client_secret))
22
+ response["data"]
23
+ end
24
+
25
+ # Creates a real-time subscription
26
+ #
27
+ # @overload create_subscription(options={})
28
+ # @param options [Hash] A set of parameters
29
+ # @option options [String] :object The object you'd like to subscribe to (user, tag, location or geography)
30
+ # @option options [String] :callback_url The subscription callback URL
31
+ # @option options [String] :aspect The aspect of the object you'd like to subscribe to (in this case, "media").
32
+ # @option options [String, Integer] :object_id When specifying a location or tag use the location's ID or tag name respectively
33
+ # @option options [String, Float] :lat The center latitude of an area, used when subscribing to a geography object
34
+ # @option options [String, Float] :lng The center longitude of an area, used when subscribing to a geography object
35
+ # @option options [String, Integer] :radius The distance in meters you'd like to capture around a given point
36
+ # @overload create_subscription(object, callback_url, aspect="media", options={})
37
+ # @param object [String] The object you'd like to subscribe to (user, tag, location or geography)
38
+ # @param callback_url [String] The subscription callback URL
39
+ # @param aspect [String] he aspect of the object you'd like to subscribe to (in this case, "media").
40
+ # @param options [Hash] Addition options and parameters
41
+ # @option options [String, Integer] :object_id When specifying a location or tag use the location's ID or tag name respectively
42
+ # @option options [String, Float] :lat The center latitude of an area, used when subscribing to a geography object
43
+ # @option options [String, Float] :lng The center longitude of an area, used when subscribing to a geography object
44
+ # @option options [String, Integer] :radius The distance in meters you'd like to capture around a given point
45
+ #
46
+ # Note that we only support "media" at this time, but we might support other types of subscriptions in the future.
47
+ # @return [Hashie::Mash] The subscription created.
48
+ # @example Creates a new subscription to receive notifications for user media changes.
49
+ # Instagram.create_subscription("user", "http://example.com/instagram/callback")
50
+ # @format :json
51
+ # @authenticated true
52
+ #
53
+ # Requires client_secret to be set on the client or passed in options
54
+ # @rate_limited true
55
+ # @see https://api.instagram.com/developer/realtime/
56
+ def create_subscription(*args)
57
+ options = args.last.is_a?(Hash) ? args.pop : {}
58
+ object = args.shift
59
+ callback_url = args.shift
60
+ aspect = args.shift
61
+ options.tap {|o|
62
+ o[:object] = object unless object.nil?
63
+ o[:callback_url] = callback_url unless callback_url.nil?
64
+ o[:aspect] = aspect || o[:aspect] || "media"
65
+ }
66
+ response = post("subscriptions", options.merge(:client_secret => client_secret))
67
+ response["data"]
68
+ end
69
+
70
+ # Deletes a real-time subscription
71
+ #
72
+ # @overload delete_subscription(options={})
73
+ # @param options [Hash] Addition options and parameters
74
+ # @option options [Integer] :subscription_id The subscription's ID
75
+ # @option options [String] :object When specified will remove all subscriptions of this object type, unless an :object_id is also specified (user, tag, location or geography)
76
+ # @option options [String, Integer] :object_id When specifying :object, inlcude an :object_id to only remove subscriptions of that object and object_id
77
+ # @overload delete_subscription(subscription_id, options={})
78
+ # @param subscription_id [Integer] The subscription's ID
79
+ # @param options [Hash] Addition options and parameters
80
+ # @option options [String] :object When specified will remove all subscriptions of this object type, unless an :object_id is also specified (user, tag, location or geography)
81
+ # @option options [String, Integer] :object_id When specifying :object, inlcude an :object_id to only remove subscriptions of that object and object_id
82
+ # @return [nil]
83
+ # @example Deletes an application's user change subscription
84
+ # Instagram.delete_subscription(:object => "user")
85
+ # @format :json
86
+ # @authenticated true
87
+ #
88
+ # Requires client_secret to be set on the client or passed in options
89
+ # @rate_limited true
90
+ # @see https://api.instagram.com/developer/realtime/
91
+ def delete_subscription(*args)
92
+ options = args.last.is_a?(Hash) ? args.pop : {}
93
+ subscription_id = args.first
94
+ options.merge!(:id => subscription_id) if subscription_id
95
+ response = delete("subscriptions", options.merge(:client_secret => client_secret))
96
+ response["data"]
97
+ end
98
+
99
+ # Process a subscription notification JSON payload
100
+ #
101
+ # @overload process_subscription(json, &block)
102
+ # @param json [String] The JSON response received by the Instagram real-time server
103
+ # @param block [Proc] A callable in which callbacks are defined
104
+ # @option options [String] :signature Pass in an X-Hub-Signature to use for payload validation
105
+ # @return [nil]
106
+ # @example Process and handle a notification for a user media change
107
+ # Instagram.process_subscription(params[:body]) do |handler|
108
+ #
109
+ # handler.on_user_changed do |user_id, data|
110
+ #
111
+ # user = User.by_instagram_id(user_id)
112
+ # @client = Instagram.client(:access_token => _access_token_for_user(user))
113
+ # latest_media = @client.user_recent_media[0]
114
+ # user.media.create_with_hash(latest_media)
115
+ # end
116
+ #
117
+ # end
118
+ # @format :json
119
+ # @authenticated true
120
+ #
121
+ # Requires client_secret to be set on the client or passed in options
122
+ # @rate_limited true
123
+ # @see https://api.instagram.com/developer/realtime/
124
+ def process_subscription(json, options={}, &block)
125
+ raise ArgumentError, "callbacks block expected" unless block_given?
126
+
127
+ if options[:signature]
128
+ if !client_secret
129
+ raise ArgumentError, "client_secret must be set during configure"
130
+ end
131
+ digest = OpenSSL::Digest::Digest.new('sha1')
132
+ verify_signature = OpenSSL::HMAC.hexdigest(digest, client_secret, json)
133
+
134
+ if options[:signature] != verify_signature
135
+ raise Instagram::InvalidSignature, "invalid X-Hub-Signature does not match verify signature against client_secret"
136
+ end
137
+ end
138
+
139
+ payload = MultiJson.decode(json)
140
+ @changes = Hash.new { |h,k| h[k] = [] }
141
+ for change in payload
142
+ @changes[change['object']] << change
143
+ end
144
+ block.call(self)
145
+ end
146
+
147
+ [:user, :tag, :location, :geography].each do |object|
148
+ class_eval <<-RUBY_EVAL, __FILE__, __LINE__ +1
149
+ def on_#{object}_changed(&block)
150
+ for change in @changes['#{object}']
151
+ yield change.delete('object_id'), change
152
+ end
153
+ end
154
+ RUBY_EVAL
155
+ end
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,59 @@
1
+ module Instagram
2
+ class Client
3
+ # Defines methods related to tags
4
+ module Tags
5
+ # Returns extended information of a given Instagram tag
6
+ #
7
+ # @overload tag(tag)
8
+ # @param tag [String] An Instagram tag name
9
+ # @return [Hashie::Mash] The requested tag.
10
+ # @example Return extended information for the tag "cat"
11
+ # Instagram.tag('cat')
12
+ # @format :json
13
+ # @authenticated false
14
+ # @rate_limited true
15
+ # @see TODO:docs url
16
+ def tag(tag, *args)
17
+ response = get("tags/#{tag}")
18
+ response["data"]
19
+ end
20
+
21
+ # Returns a list of recent media items for a given Instagram tag
22
+ #
23
+ # @overload tag_recent_media(tag, options={})
24
+ # @param user [String] An Instagram tag name.
25
+ # @param options [Hash] A customizable set of options.
26
+ # @option options [Integer] :max_id (nil) Returns results with an ID less than (that is, older than) or equal to the specified ID.
27
+ # @option options [Integer] :count (nil) Limits the number of results returned per page.
28
+ # @return [Hashie::Mash]
29
+ # @example Return a list of the most recent media items tagged "cat"
30
+ # Instagram.tag_recent_media('cat')
31
+ # @see TODO:docs url
32
+ # @format :json
33
+ # @authenticated false
34
+ # @rate_limited true
35
+ def tag_recent_media(id, *args)
36
+ options = args.last.is_a?(Hash) ? args.pop : {}
37
+ response = get("tags/#{id}/media/recent", options)
38
+ response
39
+ end
40
+
41
+ # Returns a list of tags starting with the given search query
42
+ #
43
+ # @format :json
44
+ # @authenticated false
45
+ # @rate_limited true
46
+ # @param query [String] The beginning or complete tag name to search for
47
+ # @param options [Hash] A customizable set of options.
48
+ # @option options [Integer] :count The number of media items to retrieve.
49
+ # @return [Array]
50
+ # @see TODO:doc url
51
+ # @example Return tags that start with "cat"
52
+ # Instagram.tag_search("cat")
53
+ def tag_search(query, options={})
54
+ response = get('tags/search', options.merge(:q => query))
55
+ response["data"]
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,309 @@
1
+ module Instagram
2
+ class Client
3
+ # Defines methods related to users
4
+ module Users
5
+ # Returns extended information of a given user
6
+ #
7
+ # @overload user(id=nil, options={})
8
+ # @param user [Integer] An Instagram user ID
9
+ # @return [Hashie::Mash] The requested user.
10
+ # @example Return extended information for @shayne
11
+ # Instagram.user(20)
12
+ # @format :json
13
+ # @authenticated false unless requesting it from a protected user
14
+ #
15
+ # If getting this data of a protected user, you must authenticate (and be allowed to see that user).
16
+ # @rate_limited true
17
+ # @see TODO:docs url
18
+ def user(*args)
19
+ id = args.first || 'self'
20
+ response = get("users/#{id}")
21
+ response["data"]
22
+ end
23
+
24
+ # Returns users that match the given query
25
+ #
26
+ # @format :json
27
+ # @authenticated false
28
+ # @rate_limited true
29
+ # @param query [String] The search query to run against user search.
30
+ # @param options [Hash] A customizable set of options.
31
+ # @option options [Integer] :count The number of users to retrieve.
32
+ # @return [Array]
33
+ # @see TODO:doc url
34
+ # @example Return users that match "Shayne Sweeney"
35
+ # Instagram.user_search("Shayne Sweeney")
36
+ def user_search(query, options={})
37
+ response = get('users/search', options.merge(:q => query))
38
+ response["data"]
39
+ end
40
+
41
+ # Returns a list of users whom a given user follows
42
+ #
43
+ # @overload user_follows(id=nil, options={})
44
+ # @param options [Hash] A customizable set of options.
45
+ # @return [Hashie::Mash]
46
+ # @example Returns a list of users the authenticated user follows
47
+ # Instagram.user_follows
48
+ # @overload user_follows(id=nil, options={})
49
+ # @param user [Integer] An Instagram user ID.
50
+ # @param options [Hash] A customizable set of options.
51
+ # @option options [Integer] :cursor (nil) Breaks the results into pages. Provide values as returned in the response objects's next_cursor attribute to page forward in the list.
52
+ # @option options [Integer] :count (nil) Limits the number of results returned per page.
53
+ # @return [Hashie::Mash]
54
+ # @example Return a list of users @mikeyk follows
55
+ # Instagram.user_follows(4) # @mikeyk user ID being 4
56
+ # @see TODO:docs url
57
+ # @format :json
58
+ # @authenticated false unless requesting it from a protected user
59
+ #
60
+ # If getting this data of a protected user, you must authenticate (and be allowed to see that user).
61
+ # @rate_limited true
62
+ def user_follows(*args)
63
+ options = args.last.is_a?(Hash) ? args.pop : {}
64
+ id = args.first || "self"
65
+ response = get("users/#{id}/follows", options)
66
+ response["data"]
67
+ end
68
+ end
69
+
70
+ # Returns a list of users whom a given user is followed by
71
+ #
72
+ # @overload user_followed_by(id=nil, options={})
73
+ # @param options [Hash] A customizable set of options.
74
+ # @return [Hashie::Mash]
75
+ # @example Returns a list of users the authenticated user is followed by
76
+ # Instagram.user_followed_by
77
+ # @overload user_followed_by(id=nil, options={})
78
+ # @param user [Integer] An Instagram user ID.
79
+ # @param options [Hash] A customizable set of options.
80
+ # @option options [Integer] :cursor (nil) Breaks the results into pages. Provide values as returned in the response objects's next_cursor attribute to page forward in the list.
81
+ # @option options [Integer] :count (nil) Limits the number of results returned per page.
82
+ # @return [Hashie::Mash]
83
+ # @example Return a list of users @mikeyk is followed by
84
+ # Instagram.user_followed_by(4) # @mikeyk user ID being 4
85
+ # @see TODO:docs url
86
+ # @format :json
87
+ # @authenticated false unless requesting it from a protected user
88
+ #
89
+ # If getting this data of a protected user, you must authenticate (and be allowed to see that user).
90
+ # @rate_limited true
91
+ def user_followed_by(*args)
92
+ options = args.last.is_a?(Hash) ? args.pop : {}
93
+ id = args.first || "self"
94
+ response = get("users/#{id}/followed-by", options)
95
+ response["data"]
96
+ end
97
+
98
+ # Returns a list of users whom a given user is followed by
99
+ #
100
+ # @overload user_requested_by()
101
+ # @param options [Hash] A customizable set of options.
102
+ # @return [Hashie::Mash]
103
+ # @example Returns a list of users awaiting approval of a ollow request, for the authenticated user
104
+ # Instagram.user_requested_by
105
+ # @overload user_requested_by()
106
+ # @return [Hashie::Mash]
107
+ # @example Return a list of users who have requested to follow the authenticated user
108
+ # Instagram.user_requested_by()
109
+ # @see TODO:docs url
110
+ # @format :json
111
+ # @authenticated truei
112
+ # @rate_limited true
113
+ def user_requested_by()
114
+ response = get("users/self/requested-by")
115
+ response["data"]
116
+ end
117
+
118
+ # Returns most recent media items from the currently authorized user's feed.
119
+ #
120
+ # @overload user_media_feed(options={})
121
+ # @param options [Hash] A customizable set of options.
122
+ # @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
123
+ # @option options [Integer] :min_id Return media later than this min_id
124
+ # @option options [Integer] :count Specifies the number of records to retrieve, per page.
125
+ # @return [Array]
126
+ # @example Return most recent media images that would appear on @shayne's feed
127
+ # Instagram.user_media_feed() # assuming @shayne is the authorized user
128
+ # @format :json
129
+ # @authenticated true
130
+ # @rate_limited true
131
+ # @see http://instagram.com/developer/endpoints/users/#get_users_feed
132
+ def user_media_feed(*args)
133
+ options = args.first.is_a?(Hash) ? args.pop : {}
134
+ response = get('users/self/feed', options)
135
+ response
136
+ end
137
+
138
+ # Returns a list of recent media items for a given user
139
+ #
140
+ # @overload user_recent_media(options={})
141
+ # @param options [Hash] A customizable set of options.
142
+ # @return [Hashie::Mash]
143
+ # @example Returns a list of recent media items for the currently authenticated user
144
+ # Instagram.user_recent_media
145
+ # @overload user_recent_media(id=nil, options={})
146
+ # @param user [Integer] An Instagram user ID.
147
+ # @param options [Hash] A customizable set of options.
148
+ # @option options [Integer] :max_id (nil) Returns results with an ID less than (that is, older than) or equal to the specified ID.
149
+ # @option options [Integer] :count (nil) Limits the number of results returned per page.
150
+ # @return [Hashie::Mash]
151
+ # @example Return a list of media items taken by @mikeyk
152
+ # Instagram.user_recent_media(4) # @mikeyk user ID being 4
153
+ # @see http://instagram.com/developer/endpoints/users/#get_users_media_recent
154
+ # @format :json
155
+ # @authenticated false unless requesting it from a protected user
156
+ #
157
+ # If getting this data of a protected user, you must authenticate (and be allowed to see that user).
158
+ # @rate_limited true
159
+ def user_recent_media(*args)
160
+ options = args.last.is_a?(Hash) ? args.pop : {}
161
+ id = args.first || "self"
162
+ response = get("users/#{id}/media/recent", options)
163
+ response["data"]
164
+ end
165
+
166
+ # Returns a list of media items liked by the current user
167
+ #
168
+ # @overload user_liked_media(options={})
169
+ # @param options [Hash] A customizable set of options.
170
+ # @option options [Integer] :max_like_id (nil) Returns results with an ID less than (that is, older than) or equal to the specified ID.
171
+ # @option options [Integer] :count (nil) Limits the number of results returned per page.
172
+ # @return [Hashie::Mash]
173
+ # @example Returns a list of media items liked by the currently authenticated user
174
+ # Instagram.user_liked_media
175
+ # @see http://instagram.com/developer/endpoints/users/#get_users_liked_feed
176
+ # @format :json
177
+ # @authenticated true
178
+ # @rate_limited true
179
+ def user_liked_media(options={})
180
+ response = get("users/self/media/liked", options)
181
+ response
182
+ end
183
+
184
+ # Returns information about the current user's relationship (follow/following/etc) to another user
185
+ #
186
+ # @overload user_relationship(id, options={})
187
+ # @param user [Integer] An Instagram user ID.
188
+ # @param options [Hash] An optional options hash
189
+ # @return [Hashie::Mash]
190
+ # @example Return the relationship status between the currently authenticated user and @mikeyk
191
+ # Instagram.user_relationship(4) # @mikeyk user ID being 4
192
+ # @see http://instagram.com/developer/endpoints/relationships/
193
+ # @format :json
194
+ # @authenticated true
195
+ # @rate_limited true
196
+ def user_relationship(id, options={})
197
+ response = get("users/#{id}/relationship", options)
198
+ response["data"]
199
+ end
200
+
201
+ # Create a follows relationship between the current user and the target user
202
+ #
203
+ # @overload follow_user(id, options={})
204
+ # @param user [Integer] An Instagram user ID.
205
+ # @param options [Hash] An optional options hash
206
+ # @return [Hashie::Mash]
207
+ # @example Request the current user to follow the target user
208
+ # Instagram.follow_user(4)
209
+ # @see http://instagram.com/developer/endpoints/relationships/
210
+ # @format :json
211
+ # @authenticated true
212
+ # @rate_limited true
213
+ def follow_user(id, options={})
214
+ options["action"] = "follow"
215
+ response = post("users/#{id}/relationship", options)
216
+ response["data"]
217
+ end
218
+
219
+ # Destroy a follows relationship between the current user and the target user
220
+ #
221
+ # @overload unfollow_user(id, options={})
222
+ # @param user [Integer] An Instagram user ID.
223
+ # @param options [Hash] An optional options hash
224
+ # @return [Hashie::Mash]
225
+ # @example Remove a follows relationship between the current user and the target user
226
+ # Instagram.unfollow_user(4)
227
+ # @see http://instagram.com/developer/endpoints/relationships/
228
+ # @format :json
229
+ # @authenticated true
230
+ # @rate_limited true
231
+ def unfollow_user(id, options={})
232
+ options["action"] = "unfollow"
233
+ response = post("users/#{id}/relationship", options)
234
+ response["data"]
235
+ end
236
+
237
+ # Block a relationship between the current user and the target user
238
+ #
239
+ # @overload unfollow_user(id, options={})
240
+ # @param user [Integer] An Instagram user ID.
241
+ # @param options [Hash] An optional options hash
242
+ # @return [Hashie::Mash]
243
+ # @example Block a relationship between the current user and the target user
244
+ # Instagram.block_user(4)
245
+ # @see http://instagram.com/developer/endpoints/relationships/
246
+ # @format :json
247
+ # @authenticated true
248
+ # @rate_limited true
249
+ def block_user(id, options={})
250
+ options["action"] = "block"
251
+ response = post("users/#{id}/relationship", options)
252
+ response["data"]
253
+ end
254
+
255
+ # Remove a relationship block between the current user and the target user
256
+ #
257
+ # @overload unblock_user(id, options={})
258
+ # @param user [Integer] An Instagram user ID.
259
+ # @param options [Hash] An optional options hash
260
+ # @return [Hashie::Mash]
261
+ # @example Remove a relationship block between the current user and the target user
262
+ # Instagram.unblock_user(4)
263
+ # @see http://instagram.com/developer/endpoints/relationships/
264
+ # @format :json
265
+ # @authenticated true
266
+ # @rate_limited true
267
+ def unblock_user(id, options={})
268
+ options["action"] = "unblock"
269
+ response = post("users/#{id}/relationship", options)
270
+ response["data"]
271
+ end
272
+
273
+ # Approve a relationship request between the current user and the target user
274
+ #
275
+ # @overload approve_user(id, options={})
276
+ # @param user [Integer] An Instagram user ID.
277
+ # @param options [Hash] An optional options hash
278
+ # @return [Hashie::Mash]
279
+ # @example Approve a relationship request between the current user and the target user
280
+ # Instagram.approve_user(4)
281
+ # @see http://instagram.com/developer/endpoints/relationships/
282
+ # @format :json
283
+ # @authenticated true
284
+ # @rate_limited true
285
+ def approve_user(id, options={})
286
+ options["action"] = "approve"
287
+ response = post("users/#{id}/relationship", options)
288
+ response["data"]
289
+ end
290
+
291
+ # Deny a relationship request between the current user and the target user
292
+ #
293
+ # @overload deny_user(id, options={})
294
+ # @param user [Integer] An Instagram user ID.
295
+ # @param options [Hash] An optional options hash
296
+ # @return [Hashie::Mash]
297
+ # @example Deny a relationship request between the current user and the target user
298
+ # Instagram.deny_user(4)
299
+ # @see http://instagram.com/developer/endpoints/relationships/
300
+ # @format :json
301
+ # @authenticated true
302
+ # @rate_limited true
303
+ def deny_user(id, options={})
304
+ options["action"] = "deny"
305
+ response = post("users/#{id}/relationship", options)
306
+ response["data"]
307
+ end
308
+ end
309
+ end