instagram-continued 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +7 -0
  5. data/.yardopts +9 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE.md +30 -0
  8. data/PATENTS.md +23 -0
  9. data/README.md +11 -0
  10. data/Rakefile +27 -0
  11. data/instagram.gemspec +30 -0
  12. data/lib/faraday/loud_logger.rb +75 -0
  13. data/lib/faraday/oauth2.rb +42 -0
  14. data/lib/faraday/raise_http_exception.rb +61 -0
  15. data/lib/instagram.rb +27 -0
  16. data/lib/instagram/api.rb +31 -0
  17. data/lib/instagram/client.rb +21 -0
  18. data/lib/instagram/client/comments.rb +62 -0
  19. data/lib/instagram/client/embedding.rb +28 -0
  20. data/lib/instagram/client/geographies.rb +29 -0
  21. data/lib/instagram/client/likes.rb +58 -0
  22. data/lib/instagram/client/locations.rb +75 -0
  23. data/lib/instagram/client/media.rb +82 -0
  24. data/lib/instagram/client/subscriptions.rb +211 -0
  25. data/lib/instagram/client/tags.rb +59 -0
  26. data/lib/instagram/client/users.rb +310 -0
  27. data/lib/instagram/client/utils.rb +28 -0
  28. data/lib/instagram/configuration.rb +122 -0
  29. data/lib/instagram/connection.rb +31 -0
  30. data/lib/instagram/error.rb +34 -0
  31. data/lib/instagram/oauth.rb +36 -0
  32. data/lib/instagram/request.rb +82 -0
  33. data/lib/instagram/response.rb +22 -0
  34. data/lib/instagram/version.rb +3 -0
  35. data/spec/faraday/response_spec.rb +87 -0
  36. data/spec/fixtures/access_token.json +9 -0
  37. data/spec/fixtures/approve_user.json +8 -0
  38. data/spec/fixtures/block_user.json +8 -0
  39. data/spec/fixtures/deny_user.json +8 -0
  40. data/spec/fixtures/follow_user.json +8 -0
  41. data/spec/fixtures/followed_by.json +1 -0
  42. data/spec/fixtures/follows.json +1 -0
  43. data/spec/fixtures/geography_recent_media.json +1 -0
  44. data/spec/fixtures/liked_media.json +1 -0
  45. data/spec/fixtures/location.json +1 -0
  46. data/spec/fixtures/location_recent_media.json +1 -0
  47. data/spec/fixtures/location_search.json +1 -0
  48. data/spec/fixtures/location_search_facebook.json +1 -0
  49. data/spec/fixtures/media.json +1 -0
  50. data/spec/fixtures/media_comment.json +1 -0
  51. data/spec/fixtures/media_comment_deleted.json +1 -0
  52. data/spec/fixtures/media_comments.json +1 -0
  53. data/spec/fixtures/media_liked.json +1 -0
  54. data/spec/fixtures/media_likes.json +1 -0
  55. data/spec/fixtures/media_popular.json +1 -0
  56. data/spec/fixtures/media_search.json +1 -0
  57. data/spec/fixtures/media_shortcode.json +1 -0
  58. data/spec/fixtures/media_unliked.json +1 -0
  59. data/spec/fixtures/mikeyk.json +1 -0
  60. data/spec/fixtures/oembed.json +14 -0
  61. data/spec/fixtures/recent_media.json +1 -0
  62. data/spec/fixtures/relationship.json +9 -0
  63. data/spec/fixtures/requested_by.json +12 -0
  64. data/spec/fixtures/shayne.json +1 -0
  65. data/spec/fixtures/subscription.json +12 -0
  66. data/spec/fixtures/subscription_deleted.json +1 -0
  67. data/spec/fixtures/subscription_payload.json +14 -0
  68. data/spec/fixtures/subscriptions.json +22 -0
  69. data/spec/fixtures/tag.json +1 -0
  70. data/spec/fixtures/tag_recent_media.json +1 -0
  71. data/spec/fixtures/tag_search.json +1 -0
  72. data/spec/fixtures/unblock_user.json +8 -0
  73. data/spec/fixtures/unfollow_user.json +8 -0
  74. data/spec/fixtures/user_media_feed.json +1 -0
  75. data/spec/fixtures/user_search.json +1 -0
  76. data/spec/instagram/api_spec.rb +285 -0
  77. data/spec/instagram/client/comments_spec.rb +71 -0
  78. data/spec/instagram/client/embedding_spec.rb +36 -0
  79. data/spec/instagram/client/geography_spec.rb +37 -0
  80. data/spec/instagram/client/likes_spec.rb +66 -0
  81. data/spec/instagram/client/locations_spec.rb +127 -0
  82. data/spec/instagram/client/media_spec.rb +99 -0
  83. data/spec/instagram/client/subscriptions_spec.rb +174 -0
  84. data/spec/instagram/client/tags_spec.rb +79 -0
  85. data/spec/instagram/client/users_spec.rb +432 -0
  86. data/spec/instagram/client/utils_spec.rb +32 -0
  87. data/spec/instagram/client_spec.rb +23 -0
  88. data/spec/instagram/request_spec.rb +56 -0
  89. data/spec/instagram_spec.rb +109 -0
  90. data/spec/spec_helper.rb +71 -0
  91. metadata +302 -0
@@ -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 http://instagram.com/developer/endpoints/tags/#get_tags
16
+ def tag(tag, *args)
17
+ response = get("tags/#{tag}")
18
+ response
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 tag-name [String] An Instagram tag name.
25
+ # @param options [Hash] A customizable set of options.
26
+ # @option options [Integer] :max_tag_id (nil) Returns results with an ID less than (that is, older than) or equal to the specified ID. The value can be retrieved from the returned response via pagination.max_tag_id.
27
+ # @option options [Integer] :min_tag_id (nil) Returns results with an ID greater than (that is, newer than) or equal to the specified ID. The value can be retrieved from the returned response via pagination.min_tag_id.
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 https://instagram.com/developer/endpoints/tags/#get_tags_media_recent
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, false, false, false)
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 [Hashie::Mash]
50
+ # @see http://instagram.com/developer/endpoints/tags/#get_tags_search
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
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,310 @@
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 http://instagram.com/developer/endpoints/users/#get_users
18
+ def user(*args)
19
+ options = args.last.is_a?(Hash) ? args.pop : {}
20
+ id = args.first || 'self'
21
+ response = get("users/#{id}", options)
22
+ response
23
+ end
24
+
25
+ # Returns users that match the given query
26
+ #
27
+ # @format :json
28
+ # @authenticated false
29
+ # @rate_limited true
30
+ # @param query [String] The search query to run against user search.
31
+ # @param options [Hash] A customizable set of options.
32
+ # @option options [Integer] :count The number of users to retrieve.
33
+ # @return [Hashie::Mash]
34
+ # @see http://instagram.com/developer/endpoints/users/#get_users_search
35
+ # @example Return users that match "Shayne Sweeney"
36
+ # Instagram.user_search("Shayne Sweeney")
37
+ def user_search(query, options={})
38
+ response = get('users/search', options.merge(:q => query))
39
+ response
40
+ end
41
+
42
+ # Returns a list of users whom a given user follows
43
+ #
44
+ # @overload user_follows(id=nil, options={})
45
+ # @param options [Hash] A customizable set of options.
46
+ # @return [Hashie::Mash]
47
+ # @example Returns a list of users the authenticated user follows
48
+ # Instagram.user_follows
49
+ # @overload user_follows(id=nil, options={})
50
+ # @param user [Integer] An Instagram user ID.
51
+ # @param options [Hash] A customizable set of options.
52
+ # @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.
53
+ # @option options [Integer] :count (nil) Limits the number of results returned per page.
54
+ # @return [Hashie::Mash]
55
+ # @example Return a list of users @mikeyk follows
56
+ # Instagram.user_follows(4) # @mikeyk user ID being 4
57
+ # @see http://instagram.com/developer/endpoints/relationships/#get_users_follows
58
+ # @format :json
59
+ # @authenticated false unless requesting it from a protected user
60
+ #
61
+ # If getting this data of a protected user, you must authenticate (and be allowed to see that user).
62
+ # @rate_limited true
63
+ def user_follows(*args)
64
+ options = args.last.is_a?(Hash) ? args.pop : {}
65
+ id = args.first || "self"
66
+ response = get("users/#{id}/follows", options)
67
+ response
68
+ end
69
+ end
70
+
71
+ # Returns a list of users whom a given user is followed by
72
+ #
73
+ # @overload user_followed_by(id=nil, options={})
74
+ # @param options [Hash] A customizable set of options.
75
+ # @return [Hashie::Mash]
76
+ # @example Returns a list of users the authenticated user is followed by
77
+ # Instagram.user_followed_by
78
+ # @overload user_followed_by(id=nil, options={})
79
+ # @param user [Integer] An Instagram user ID.
80
+ # @param options [Hash] A customizable set of options.
81
+ # @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.
82
+ # @option options [Integer] :count (nil) Limits the number of results returned per page.
83
+ # @return [Hashie::Mash]
84
+ # @example Return a list of users @mikeyk is followed by
85
+ # Instagram.user_followed_by(4) # @mikeyk user ID being 4
86
+ # @see http://instagram.com/developer/endpoints/relationships/#get_users_followed_by
87
+ # @format :json
88
+ # @authenticated false unless requesting it from a protected user
89
+ #
90
+ # If getting this data of a protected user, you must authenticate (and be allowed to see that user).
91
+ # @rate_limited true
92
+ def user_followed_by(*args)
93
+ options = args.last.is_a?(Hash) ? args.pop : {}
94
+ id = args.first || "self"
95
+ response = get("users/#{id}/followed-by", options)
96
+ response
97
+ end
98
+
99
+ # Returns a list of users who have requested the currently authorized user's permission to follow
100
+ #
101
+ # @overload user_requested_by()
102
+ # @param options [Hash] A customizable set of options.
103
+ # @return [Hashie::Mash]
104
+ # @example Returns a list of users awaiting approval of a ollow request, for the authenticated user
105
+ # Instagram.user_requested_by
106
+ # @overload user_requested_by()
107
+ # @return [Hashie::Mash]
108
+ # @example Return a list of users who have requested to follow the authenticated user
109
+ # Instagram.user_requested_by()
110
+ # @see http://instagram.com/developer/endpoints/relationships/#get_incoming_requests
111
+ # @format :json
112
+ # @authenticated true
113
+ # @rate_limited true
114
+ def user_requested_by()
115
+ response = get("users/self/requested-by")
116
+ response
117
+ end
118
+
119
+ # Returns most recent media items from the currently authorized user's feed
120
+ #
121
+ # @overload user_media_feed(options={})
122
+ # @param options [Hash] A customizable set of options.
123
+ # @option options [Integer] :max_id Returns results with an ID less than (that is, older than) or equal to the specified ID.
124
+ # @option options [Integer] :min_id Return media later than this min_id
125
+ # @option options [Integer] :count Specifies the number of records to retrieve, per page.
126
+ # @return [Hashie::Mash]
127
+ # @example Return most recent media images that would appear on @shayne's feed
128
+ # Instagram.user_media_feed() # assuming @shayne is the authorized user
129
+ # @format :json
130
+ # @authenticated true
131
+ # @rate_limited true
132
+ # @see http://instagram.com/developer/endpoints/users/#get_users_feed
133
+ def user_media_feed(*args)
134
+ options = args.first.is_a?(Hash) ? args.pop : {}
135
+ response = get('users/self/feed', options)
136
+ response
137
+ end
138
+
139
+ # Returns a list of recent media items for a given user
140
+ #
141
+ # @overload user_recent_media(options={})
142
+ # @param options [Hash] A customizable set of options.
143
+ # @return [Hashie::Mash]
144
+ # @example Returns a list of recent media items for the currently authenticated user
145
+ # Instagram.user_recent_media
146
+ # @overload user_recent_media(id=nil, options={})
147
+ # @param user [Integer] An Instagram user ID.
148
+ # @param options [Hash] A customizable set of options.
149
+ # @option options [Integer] :max_id (nil) Returns results with an ID less than (that is, older than) or equal to the specified ID.
150
+ # @option options [Integer] :count (nil) Limits the number of results returned per page.
151
+ # @return [Hashie::Mash]
152
+ # @example Return a list of media items taken by @mikeyk
153
+ # Instagram.user_recent_media(4) # @mikeyk user ID being 4
154
+ # @see http://instagram.com/developer/endpoints/users/#get_users_media_recent
155
+ # @format :json
156
+ # @authenticated false unless requesting it from a protected user
157
+ #
158
+ # If getting this data of a protected user, you must authenticate (and be allowed to see that user).
159
+ # @rate_limited true
160
+ def user_recent_media(*args)
161
+ options = args.last.is_a?(Hash) ? args.pop : {}
162
+ id = args.first || "self"
163
+ response = get("users/#{id}/media/recent", options)
164
+ response
165
+ end
166
+
167
+ # Returns a list of media items liked by the current user
168
+ #
169
+ # @overload user_liked_media(options={})
170
+ # @param options [Hash] A customizable set of options.
171
+ # @option options [Integer] :max_like_id (nil) Returns results with an ID less than (that is, older than) or equal to the specified ID.
172
+ # @option options [Integer] :count (nil) Limits the number of results returned per page.
173
+ # @return [Hashie::Mash]
174
+ # @example Returns a list of media items liked by the currently authenticated user
175
+ # Instagram.user_liked_media
176
+ # @see http://instagram.com/developer/endpoints/users/#get_users_liked_feed
177
+ # @format :json
178
+ # @authenticated true
179
+ # @rate_limited true
180
+ def user_liked_media(options={})
181
+ response = get("users/self/media/liked", options)
182
+ response
183
+ end
184
+
185
+ # Returns information about the current user's relationship (follow/following/etc) to another user
186
+ #
187
+ # @overload user_relationship(id, options={})
188
+ # @param user [Integer] An Instagram user ID.
189
+ # @param options [Hash] An optional options hash
190
+ # @return [Hashie::Mash]
191
+ # @example Return the relationship status between the currently authenticated user and @mikeyk
192
+ # Instagram.user_relationship(4) # @mikeyk user ID being 4
193
+ # @see http://instagram.com/developer/endpoints/relationships/#get_relationship
194
+ # @format :json
195
+ # @authenticated true
196
+ # @rate_limited true
197
+ def user_relationship(id, options={})
198
+ response = get("users/#{id}/relationship", options)
199
+ response
200
+ end
201
+
202
+ # Create a follows relationship between the current user and the target user
203
+ #
204
+ # @overload follow_user(id, options={})
205
+ # @param user [Integer] An Instagram user ID.
206
+ # @param options [Hash] An optional options hash
207
+ # @return [Hashie::Mash]
208
+ # @example Request the current user to follow the target user
209
+ # Instagram.follow_user(4)
210
+ # @see http://instagram.com/developer/endpoints/relationships/#post_relationship
211
+ # @format :json
212
+ # @authenticated true
213
+ # @rate_limited true
214
+ def follow_user(id, options={})
215
+ options["action"] = "follow"
216
+ response = post("users/#{id}/relationship", options, signature=true)
217
+ response
218
+ end
219
+
220
+ # Destroy a follows relationship between the current user and the target user
221
+ #
222
+ # @overload unfollow_user(id, options={})
223
+ # @param user [Integer] An Instagram user ID.
224
+ # @param options [Hash] An optional options hash
225
+ # @return [Hashie::Mash]
226
+ # @example Remove a follows relationship between the current user and the target user
227
+ # Instagram.unfollow_user(4)
228
+ # @see http://instagram.com/developer/endpoints/relationships/#post_relationship
229
+ # @format :json
230
+ # @authenticated true
231
+ # @rate_limited true
232
+ def unfollow_user(id, options={})
233
+ options["action"] = "unfollow"
234
+ response = post("users/#{id}/relationship", options, signature=true)
235
+ response
236
+ end
237
+
238
+ # Block a relationship between the current user and the target user
239
+ #
240
+ # @overload unfollow_user(id, options={})
241
+ # @param user [Integer] An Instagram user ID.
242
+ # @param options [Hash] An optional options hash
243
+ # @return [Hashie::Mash]
244
+ # @example Block a relationship between the current user and the target user
245
+ # Instagram.block_user(4)
246
+ # @see http://instagram.com/developer/endpoints/relationships/#post_relationship
247
+ # @format :json
248
+ # @authenticated true
249
+ # @rate_limited true
250
+ def block_user(id, options={})
251
+ options["action"] = "block"
252
+ response = post("users/#{id}/relationship", options, signature=true)
253
+ response
254
+ end
255
+
256
+ # Remove a relationship block between the current user and the target user
257
+ #
258
+ # @overload unblock_user(id, options={})
259
+ # @param user [Integer] An Instagram user ID.
260
+ # @param options [Hash] An optional options hash
261
+ # @return [Hashie::Mash]
262
+ # @example Remove a relationship block between the current user and the target user
263
+ # Instagram.unblock_user(4)
264
+ # @see http://instagram.com/developer/endpoints/relationships/#post_relationship
265
+ # @format :json
266
+ # @authenticated true
267
+ # @rate_limited true
268
+ def unblock_user(id, options={})
269
+ options["action"] = "unblock"
270
+ response = post("users/#{id}/relationship", options, signature=true)
271
+ response
272
+ end
273
+
274
+ # Approve a relationship request between the current user and the target user
275
+ #
276
+ # @overload approve_user(id, options={})
277
+ # @param user [Integer] An Instagram user ID.
278
+ # @param options [Hash] An optional options hash
279
+ # @return [Hashie::Mash]
280
+ # @example Approve a relationship request between the current user and the target user
281
+ # Instagram.approve_user(4)
282
+ # @see http://instagram.com/developer/endpoints/relationships/#post_relationship
283
+ # @format :json
284
+ # @authenticated true
285
+ # @rate_limited true
286
+ def approve_user(id, options={})
287
+ options["action"] = "approve"
288
+ response = post("users/#{id}/relationship", options, signature=true)
289
+ response
290
+ end
291
+
292
+ # Deny a relationship request between the current user and the target user
293
+ #
294
+ # @overload deny_user(id, options={})
295
+ # @param user [Integer] An Instagram user ID.
296
+ # @param options [Hash] An optional options hash
297
+ # @return [Hashie::Mash]
298
+ # @example Deny a relationship request between the current user and the target user
299
+ # Instagram.deny_user(4)
300
+ # @see http://instagram.com/developer/endpoints/relationships/#post_relationship
301
+ # @format :json
302
+ # @authenticated true
303
+ # @rate_limited true
304
+ def deny_user(id, options={})
305
+ options["action"] = "deny"
306
+ response = post("users/#{id}/relationship", options, signature=true)
307
+ response
308
+ end
309
+ end
310
+ end
@@ -0,0 +1,28 @@
1
+ module Instagram
2
+ class Client
3
+ # @private
4
+ module Utils
5
+ # Returns the raw full response including all headers. Can be used to access the values for 'X-Ratelimit-Limit' and 'X-Ratelimit-Remaining'
6
+ # ==== Examples
7
+ #
8
+ # client = Instagram.client(:access_token => session[:access_token])
9
+ # response = client.utils_raw_response
10
+ # remaining = response.headers[:x_ratelimit_remaining]
11
+ # limit = response.headers[:x_ratelimit_limit]
12
+ #
13
+ def utils_raw_response
14
+ response = get('users/self/feed',nil, false, true)
15
+ response
16
+ end
17
+
18
+ private
19
+
20
+ # Returns the configured user name or the user name of the authenticated user
21
+ #
22
+ # @return [String]
23
+ def get_username
24
+ @user_name ||= self.user.username
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,122 @@
1
+ require 'faraday'
2
+ require File.expand_path('../version', __FILE__)
3
+
4
+ module Instagram
5
+ # Defines constants and methods related to configuration
6
+ module Configuration
7
+ # An array of valid keys in the options hash when configuring a {Instagram::API}
8
+ VALID_OPTIONS_KEYS = [
9
+ :access_token,
10
+ :adapter,
11
+ :client_id,
12
+ :client_secret,
13
+ :client_ips,
14
+ :connection_options,
15
+ :scope,
16
+ :redirect_uri,
17
+ :endpoint,
18
+ :format,
19
+ :proxy,
20
+ :user_agent,
21
+ :no_response_wrapper,
22
+ :loud_logger,
23
+ :sign_requests,
24
+ ].freeze
25
+
26
+ # By default, don't set a user access token
27
+ DEFAULT_ACCESS_TOKEN = nil
28
+
29
+ # The adapter that will be used to connect if none is set
30
+ #
31
+ # @note The default faraday adapter is Net::HTTP.
32
+ DEFAULT_ADAPTER = Faraday.default_adapter
33
+
34
+ # By default, don't set an application ID
35
+ DEFAULT_CLIENT_ID = nil
36
+
37
+ # By default, don't set an application secret
38
+ DEFAULT_CLIENT_SECRET = nil
39
+
40
+ # By default, don't set application IPs
41
+ DEFAULT_CLIENT_IPS = nil
42
+
43
+ # By default, don't set any connection options
44
+ DEFAULT_CONNECTION_OPTIONS = {}
45
+
46
+ # The endpoint that will be used to connect if none is set
47
+ #
48
+ # @note There is no reason to use any other endpoint at this time
49
+ DEFAULT_ENDPOINT = 'https://api.instagram.com/v1/'.freeze
50
+
51
+ # The response format appended to the path and sent in the 'Accept' header if none is set
52
+ #
53
+ # @note JSON is the only available format at this time
54
+ DEFAULT_FORMAT = :json
55
+
56
+ # By default, don't use a proxy server
57
+ DEFAULT_PROXY = nil
58
+
59
+ # By default, don't set an application redirect uri
60
+ DEFAULT_REDIRECT_URI = nil
61
+
62
+ # By default, don't set a user scope
63
+ DEFAULT_SCOPE = nil
64
+
65
+ # By default, don't wrap responses with meta data (i.e. pagination)
66
+ DEFAULT_NO_RESPONSE_WRAPPER = false
67
+
68
+ # The user agent that will be sent to the API endpoint if none is set
69
+ DEFAULT_USER_AGENT = "Instagram Ruby Gem #{Instagram::VERSION}".freeze
70
+
71
+ # An array of valid request/response formats
72
+ #
73
+ # @note Not all methods support the XML format.
74
+ VALID_FORMATS = [
75
+ :json].freeze
76
+
77
+ # By default, don't turn on loud logging
78
+ DEFAULT_LOUD_LOGGER = nil
79
+
80
+ # By default, requests are not signed
81
+ DEFAULT_SIGN_REQUESTS = false
82
+
83
+ # @private
84
+ attr_accessor *VALID_OPTIONS_KEYS
85
+
86
+ # When this module is extended, set all configuration options to their default values
87
+ def self.extended(base)
88
+ base.reset
89
+ end
90
+
91
+ # Convenience method to allow configuration options to be set in a block
92
+ def configure
93
+ yield self
94
+ end
95
+
96
+ # Create a hash of options and their values
97
+ def options
98
+ VALID_OPTIONS_KEYS.inject({}) do |option, key|
99
+ option.merge!(key => send(key))
100
+ end
101
+ end
102
+
103
+ # Reset all configuration options to defaults
104
+ def reset
105
+ self.access_token = DEFAULT_ACCESS_TOKEN
106
+ self.adapter = DEFAULT_ADAPTER
107
+ self.client_id = DEFAULT_CLIENT_ID
108
+ self.client_secret = DEFAULT_CLIENT_SECRET
109
+ self.client_ips = DEFAULT_CLIENT_IPS
110
+ self.connection_options = DEFAULT_CONNECTION_OPTIONS
111
+ self.scope = DEFAULT_SCOPE
112
+ self.redirect_uri = DEFAULT_REDIRECT_URI
113
+ self.endpoint = DEFAULT_ENDPOINT
114
+ self.format = DEFAULT_FORMAT
115
+ self.proxy = DEFAULT_PROXY
116
+ self.user_agent = DEFAULT_USER_AGENT
117
+ self.no_response_wrapper= DEFAULT_NO_RESPONSE_WRAPPER
118
+ self.loud_logger = DEFAULT_LOUD_LOGGER
119
+ self.sign_requests = DEFAULT_SIGN_REQUESTS
120
+ end
121
+ end
122
+ end