instagram 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZjMwYTJjMDZmZjY3NmM4M2UzN2Q2MTZiMmIzMjJkMDQ3YWY2NThmMQ==
4
+ M2Y3MDRiMGZmYTMzMzk1MDVkYTc3MGRjYTBjNWM5ZjFhMjY5NDA4Zg==
5
5
  data.tar.gz: !binary |-
6
- NjVhMWE1ZjRiNDVhODI5ZTQ1MzhlOTg1NjQyZDRkZTgyMzMxMjFmZg==
6
+ ZTY4N2RkYzBmYTdkNWZlM2ExNTgzN2FjNzhmYWQ5OGU3YjA0M2JiYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmRmYzc4Y2FkYjMxYTEzNTkxYzViNmQxNTUwOWZlZjMwNmVmNDU1MmI3NzE0
10
- ODg1Y2M2Y2YyNGM5NTY1M2I1MDAxM2Y3NThlMTAyYjQxNjIxY2ZlMTgwYzhk
11
- NzRlMTk4NDJkY2JkMWQ4YmY4MTUyNDJkMmQyMjliODNkMGMxOGM=
9
+ NjY2Nzg2MjM1YmIwYTM5MDVjYzRiMmZlNDdlNDY1YWFlYzZhN2ExMWE2NDZm
10
+ NTI0NzIxNDkxMTNiMWIxYWMyZGMzZjE1ZGYxOWM2YWQ1MGQ3ZWEwMzJmZWU3
11
+ NjJmMGEzMWY5YTUyZGQwOGIxZGIyOWZmNDk0ZjhiMDU3N2QwYjY=
12
12
  data.tar.gz: !binary |-
13
- ODRmODMzZjY3Y2JjNWE4OGJhOTEzMzQxNGRmN2VhNDJjNGNkZGM1YWNmOGVh
14
- NmZkMWZiYTM1MTc4MWE1MzRlMzllNzJjZTg5OTUyMzQ3NmU5YTI5ZGQ5MDAx
15
- YmI2MmU1OWM3YWI2ZDNiNjkzNzA0ODIxMDRjZDIwYTkxMWRjMTM=
13
+ ZmZhOTBhYTRiODQ1ZjE5ODZjM2RlN2IwYzBjMWM5NDUxMGQwYmM5MmQ3YWEx
14
+ YjQ5YzRjMTFjODUxOTVmNGE0ZGMyMDNjNzVlMWY0NmNlYTAzYjM2MzBhY2Vi
15
+ ODE3YTljY2ViYjdiZmZlNzRjNGM0YmUwMmRhZWE3MTAzYTcwYjc=
data/README.md CHANGED
@@ -250,5 +250,5 @@ Complete your CLA here: [https://code.facebook.com/cla](https://code.facebook.co
250
250
  Copyright
251
251
  ---------
252
252
  Copyright (c) 2014, Facebook, Inc. All rights reserved.
253
- By contributing to Instgram Ruby Gem, you agree that your contributions will be licensed under its BSD license.
253
+ By contributing to Instagram Ruby Gem, you agree that your contributions will be licensed under its BSD license.
254
254
  See [LICENSE](https://github.com/Instagram/instagram-ruby-gem/blob/master/LICENSE.md) for details.
@@ -5,7 +5,7 @@ Gem::Specification.new do |s|
5
5
  s.add_development_dependency('rake', '~> 0.9.2.2')
6
6
  s.add_development_dependency('rspec', '~> 2.4')
7
7
  s.add_development_dependency('webmock', '~> 1.6')
8
- s.add_development_dependency('bluecloth', '~> 2.0.11')
8
+ s.add_development_dependency('bluecloth', '~> 2.2.0')
9
9
  s.add_runtime_dependency('faraday', ['>= 0.7', '< 0.10'])
10
10
  s.add_runtime_dependency('faraday_middleware', ['>= 0.8', '< 0.10'])
11
11
  s.add_runtime_dependency('multi_json', '>= 1.0.3', '~> 1.0')
@@ -23,6 +23,7 @@ module Instagram
23
23
  # @overload location_recent_media(id, options={})
24
24
  # @param user [Integer] An Instagram location ID.
25
25
  # @param options [Hash] A customizable set of options.
26
+ # @option options [Integer] :max_timestamp (nil) Return media before this UNIX timestamp
26
27
  # @option options [Integer] :max_id (nil) Returns results with an ID less than (that is, older than) or equal to the specified ID.
27
28
  # @option options [Integer] :count (nil) Limits the number of results returned per page.
28
29
  # @return [Hashie::Mash]
@@ -21,6 +21,25 @@ module Instagram
21
21
  response
22
22
  end
23
23
 
24
+ # Returns extended information of a given media item
25
+ #
26
+ # @overload media_shortcode(shortcode)
27
+ # @param shortcode [String] An Instagram media item shortcode
28
+ # @return [Hashie::Mash] The requested media item.
29
+ # @example Return extended information for media item with shortcode 'D'
30
+ # Instagram.media_shortcode('D')
31
+ # @format none
32
+ # @authenticated false unless requesting media from a protected user
33
+ #
34
+ # If getting this data of a protected user, you must authenticate (and be allowed to see that user).
35
+ # @rate_limited true
36
+ # @see http://instagram.com/developer/endpoints/media/#get_media_by_shortcode
37
+ def media_shortcode(*args)
38
+ shortcode = args.first
39
+ response = get("media/shortcode/#{shortcode}", {}, false, false, true)
40
+ response
41
+ end
42
+
24
43
  # Returns a list of the overall most popular media
25
44
  #
26
45
  # @overload media_popular(options={})
@@ -126,7 +126,7 @@ module Instagram
126
126
  end
127
127
 
128
128
  # Public: As a security measure, all updates from Instagram are signed using
129
- # X-Hub-Signature: sha1=XXXX where XXX is the sha1 of the json payload
129
+ # X-Hub-Signature: XXXX where XXX is the sha1 of the json payload
130
130
  # using your application secret as the key.
131
131
  #
132
132
  # Example:
@@ -143,9 +143,7 @@ module Instagram
143
143
  raise ArgumentError, "client_secret must be set during configure"
144
144
  end
145
145
 
146
- if request_signature = headers['X-Hub-Signature'] || headers['HTTP_X_HUB_SIGNATURE'] and
147
- signature_parts = request_signature.split('sha1=')
148
- request_signature = signature_parts[1]
146
+ if request_signature = headers['X-Hub-Signature'] || headers['HTTP_X_HUB_SIGNATURE']
149
147
  calculated_signature = OpenSSL::HMAC.hexdigest('sha1', client_secret, body)
150
148
  calculated_signature == request_signature
151
149
  end
@@ -23,12 +23,12 @@ module Instagram
23
23
  # @overload tag_recent_media(tag, options={})
24
24
  # @param tag-name [String] An Instagram tag name.
25
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] :min_id (nil) Returns results with an ID greater than (that is, newer than) or equal to the specified ID.
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
28
  # @return [Hashie::Mash]
29
29
  # @example Return a list of the most recent media items tagged "cat"
30
30
  # Instagram.tag_recent_media('cat')
31
- # @see http://instagram.com/developer/endpoints/tags/#get_tags_media_recent
31
+ # @see https://instagram.com/developer/endpoints/tags/#get_tags_media_recent
32
32
  # @format :json
33
33
  # @authenticated false
34
34
  # @rate_limited true
@@ -5,22 +5,22 @@ module Instagram
5
5
  # Defines HTTP request methods
6
6
  module Request
7
7
  # Perform an HTTP GET request
8
- def get(path, options={}, signature=false, raw=false, unformatted=false, no_response_wrapper=no_response_wrapper)
8
+ def get(path, options={}, signature=false, raw=false, unformatted=false, no_response_wrapper=no_response_wrapper())
9
9
  request(:get, path, options, signature, raw, unformatted, no_response_wrapper)
10
10
  end
11
11
 
12
12
  # Perform an HTTP POST request
13
- def post(path, options={}, signature=false, raw=false, unformatted=false, no_response_wrapper=no_response_wrapper)
13
+ def post(path, options={}, signature=false, raw=false, unformatted=false, no_response_wrapper=no_response_wrapper())
14
14
  request(:post, path, options, signature, raw, unformatted, no_response_wrapper)
15
15
  end
16
16
 
17
17
  # Perform an HTTP PUT request
18
- def put(path, options={}, signature=false, raw=false, unformatted=false, no_response_wrapper=no_response_wrapper)
18
+ def put(path, options={}, signature=false, raw=false, unformatted=false, no_response_wrapper=no_response_wrapper())
19
19
  request(:put, path, options, signature, raw, unformatted, no_response_wrapper)
20
20
  end
21
21
 
22
22
  # Perform an HTTP DELETE request
23
- def delete(path, options={}, signature=false, raw=false, unformatted=false, no_response_wrapper=no_response_wrapper)
23
+ def delete(path, options={}, signature=false, raw=false, unformatted=false, no_response_wrapper=no_response_wrapper())
24
24
  request(:delete, path, options, signature, raw, unformatted, no_response_wrapper)
25
25
  end
26
26
 
@@ -43,7 +43,8 @@ module Instagram
43
43
  end
44
44
  return response if raw
45
45
  return response.body if no_response_wrapper
46
- return Response.create( response.body )
46
+ return Response.create( response.body, {:limit => response.headers['x-ratelimit-limit'].to_i,
47
+ :remaining => response.headers['x-ratelimit-remaining'].to_i} )
47
48
  end
48
49
 
49
50
  def formatted_path(path)
@@ -1,16 +1,21 @@
1
1
  module Instagram
2
2
  module Response
3
- def self.create( response_hash )
3
+ def self.create( response_hash, ratelimit_hash )
4
4
  data = response_hash.data.dup rescue response_hash
5
5
  data.extend( self )
6
6
  data.instance_exec do
7
- @pagination = response_hash.pagination
8
- @meta = response_hash.meta
7
+ %w{pagination meta}.each do |k|
8
+ response_hash.public_send(k).tap do |v|
9
+ instance_variable_set("@#{k}", v) if v
10
+ end
11
+ end
12
+ ratelimit = ::Hashie::Mash.new(ratelimit_hash)
9
13
  end
10
14
  data
11
15
  end
12
16
 
13
17
  attr_reader :pagination
14
18
  attr_reader :meta
19
+ attr_reader :ratelimit
15
20
  end
16
21
  end
@@ -1,3 +1,3 @@
1
1
  module Instagram
2
- VERSION = '1.1.3'.freeze unless defined?(::Instagram::VERSION)
2
+ VERSION = '1.1.4'.freeze unless defined?(::Instagram::VERSION)
3
3
  end
@@ -0,0 +1 @@
1
+ {"meta":{"code":200},"data":{"attribution":null,"tags":["youknowitslate"],"type":"image","location":null,"comments":{"count":3,"data":[{"created_time":"1295535132","text":"Nice","from":{"username":"newyorkcity","profile_picture":"http:\/\/images.ak.instagram.com\/profiles\/profile_1483611_75sq_1391632115.jpg","id":"1483611","full_name":"newyorkcity"},"id":"20808205"},{"created_time":"1295549402","text":"I hope you guys got some good work done :)","from":{"username":"abelnation","profile_picture":"http:\/\/images.ak.instagram.com\/profiles\/profile_5315_75sq_1391467051.jpg","id":"5315","full_name":"Abel Allison"},"id":"20873301"},{"created_time":"1295556861","text":"Hey do you follow @docpop ?Him, and his friend, made a pretty awesome Instagram Scarf.","from":{"username":"jasonsposa","profile_picture":"http:\/\/photos-c.ak.instagram.com\/hphotos-ak-xaf1\/10616446_1460074390927282_1108706618_a.jpg","id":"102516","full_name":"jason"},"id":"20900554"}]},"filter":"X-Pro II","created_time":"1295525094","link":"http:\/\/instagram.com\/p\/BG9It\/","likes":{"count":52,"data":[{"username":"bailey","profile_picture":"http:\/\/images.ak.instagram.com\/profiles\/profile_120_75sq_1328690799.jpg","id":"120","full_name":"Bailey Siewert"},{"username":"bill","profile_picture":"http:\/\/photos-h.ak.instagram.com\/hphotos-ak-xfa1\/10597268_695384913848791_1949499102_a.jpg","id":"34","full_name":"Bill Bogenschutz"},{"username":"juss0445","profile_picture":"http:\/\/images.ak.instagram.com\/profiles\/profile_1416773_75sq_1296220025.jpg","id":"1416773","full_name":"juss0445"},{"username":"mimidea","profile_picture":"http:\/\/images.ak.instagram.com\/profiles\/profile_1133519_75sq_1361436617.jpg","id":"1133519","full_name":"mimi\ud83d\udc95"}]},"images":{"low_resolution":{"url":"http:\/\/scontent-a.cdninstagram.com\/hphotos-xfa1\/outbound-distillery\/t0.0-17\/OBPTH\/media\/2011\/01\/20\/6248835b0acd48d39d7ee606937ae9f7_6.jpg","width":306,"height":306},"thumbnail":{"url":"http:\/\/scontent-a.cdninstagram.com\/hphotos-xfa1\/outbound-distillery\/t0.0-17\/OBPTH\/media\/2011\/01\/20\/6248835b0acd48d39d7ee606937ae9f7_5.jpg","width":150,"height":150},"standard_resolution":{"url":"http:\/\/scontent-a.cdninstagram.com\/hphotos-xfa1\/outbound-distillery\/t0.0-17\/OBPTH\/media\/2011\/01\/20\/6248835b0acd48d39d7ee606937ae9f7_7.jpg","width":612,"height":612}},"users_in_photo":[],"caption":{"created_time":"1295525094","text":"#youknowitslate when the cab driver wishes you good morning","from":{"username":"mikeyk","profile_picture":"http:\/\/images.ak.instagram.com\/profiles\/profile_4_75sq_1374110869.jpg","id":"4","full_name":"Mike Krieger"},"id":"20757161"},"user_has_liked":false,"id":"18600493_4","user":{"username":"mikeyk","website":"","profile_picture":"http:\/\/images.ak.instagram.com\/profiles\/profile_4_75sq_1374110869.jpg","full_name":"Mike Krieger","bio":"","id":"4"}}}
@@ -28,6 +28,27 @@ describe Instagram::Client do
28
28
  end
29
29
  end
30
30
 
31
+ describe ".media_shortcode" do
32
+
33
+ before do
34
+ stub_get('media/shortcode/BG9It').
35
+ with(:query => {:access_token => @client.access_token}).
36
+ to_return(:body => fixture("media_shortcode.#{format}"), :headers => {:content_type => "application/#{format}; charset=utf-8"})
37
+ end
38
+
39
+ it "should get the correct resource" do
40
+ @client.media_shortcode('BG9It')
41
+ a_get('media/shortcode/BG9It').
42
+ with(:query => {:access_token => @client.access_token}).
43
+ should have_been_made
44
+ end
45
+
46
+ it "should return extended information of a given media item" do
47
+ media = @client.media_shortcode('BG9It')
48
+ media.user.username.should == 'mikeyk'
49
+ end
50
+ end
51
+
31
52
  describe ".media_popular" do
32
53
 
33
54
  before do
@@ -67,6 +67,29 @@ describe Instagram::Client do
67
67
  end
68
68
  end
69
69
 
70
+ describe ".validate_update" do
71
+
72
+ subject { @client.validate_update(body, headers) }
73
+
74
+ context "when calculated signature matches request signature" do
75
+
76
+ let(:body) { {foo: "bar"}.to_json }
77
+ let(:request_signature) { OpenSSL::HMAC.hexdigest('sha1', @client.client_secret, body) }
78
+ let(:headers) { {"X-Hub-Signature" => request_signature} }
79
+
80
+ it { expect(subject).to be_true }
81
+ end
82
+
83
+ context "when calculated signature does not match request signature" do
84
+
85
+ let(:body) { {foo: "bar"}.to_json }
86
+ let(:request_signature) { "going to fail" }
87
+ let(:headers) { {"X-Hub-Signature" => request_signature} }
88
+
89
+ it { expect(subject).to be_false }
90
+ end
91
+ end
92
+
70
93
  describe ".process_subscriptions" do
71
94
 
72
95
  context "without a callbacks block" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instagram
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shayne Sweeney
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-26 00:00:00.000000000 Z
11
+ date: 2015-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 2.0.11
61
+ version: 2.2.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: 2.0.11
68
+ version: 2.2.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: faraday
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -201,6 +201,7 @@ files:
201
201
  - spec/fixtures/media_likes.json
202
202
  - spec/fixtures/media_popular.json
203
203
  - spec/fixtures/media_search.json
204
+ - spec/fixtures/media_shortcode.json
204
205
  - spec/fixtures/media_unliked.json
205
206
  - spec/fixtures/mikeyk.json
206
207
  - spec/fixtures/oembed.json
@@ -322,6 +323,7 @@ test_files:
322
323
  - spec/fixtures/media_likes.json
323
324
  - spec/fixtures/media_popular.json
324
325
  - spec/fixtures/media_search.json
326
+ - spec/fixtures/media_shortcode.json
325
327
  - spec/fixtures/media_unliked.json
326
328
  - spec/fixtures/mikeyk.json
327
329
  - spec/fixtures/oembed.json