instagram_basic_display 0.1.1 → 0.2.0

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3f846370332088bbcaf50f63a7d8398e04d04466c9c8cf9e82c03d830f90d5c
4
- data.tar.gz: 76e33e69f8a1125a4fbf02d6589a98ad702dfaea37ff0da6768ff53e397ffbcb
3
+ metadata.gz: f91c7c3b242f6488c78b3cfafb99ec3ae263c3ce158c8bdfd0a29c6a4a515241
4
+ data.tar.gz: 0107b170ee8997987a12a0c8136d5346150c70e555b36f20bc381ea30ad3f7f6
5
5
  SHA512:
6
- metadata.gz: 8db44440f119f41fd42414547618b309c9e957f9a6760dde36482bed5a08c14a97704f5a4355601384e09a9d16e157bd5098af79f53410ce2914b99f53cc273f
7
- data.tar.gz: 6527b43d17eccee89260bec21b1f9f3719b2a8633afb82ff92a119b2de3e206f5a3d380d254810cf46af6af1083f06c6282c5a687c23a866b32e28332ecd0b0c
6
+ metadata.gz: e4c9a9b95abc448be189ddd0c024bb24412aff97feb75a551219810e1cbe39aa5bc1ef991b34402b8a919bc21953675ac8e18e78c2238e7214aabb3921eca4f5
7
+ data.tar.gz: d4b1ae2e93ff561878f7d71acba22ce318709013f1fe43de29b2409853c486c44a0f06c0c9de512fb705e94c28de61cf732af88fedad6d8423e519c276f97f67
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- instagram_basic_display (0.1.1)
4
+ instagram_basic_display (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -39,10 +39,15 @@ module InstagramBasicDisplay
39
39
  end
40
40
 
41
41
  # document that you can add a limit here
42
- def media_feed(user_id: nil, fields: %i[id media_url], **params)
42
+ def media_feed(user_id: nil, fields: %i[id media_url], paginated_url: nil, **params)
43
43
  check_for_auth_token!(params)
44
44
 
45
- uri = URI(base_profile_uri(user_id: user_id) + '/media')
45
+ uri = if paginated_url
46
+ URI(paginated_url)
47
+ else
48
+ URI(base_profile_uri(user_id: user_id) + '/media')
49
+ end
50
+
46
51
  params = {
47
52
  fields: fields.map(&:to_s).join(','),
48
53
  access_token: configuration.auth_token,
@@ -52,10 +57,6 @@ module InstagramBasicDisplay
52
57
  make_request(uri, params)
53
58
  end
54
59
 
55
- def media_feed_from_link(page_link:)
56
- uri = URI(page_link)
57
- make_request(uri)
58
- end
59
60
 
60
61
  def media_node(media_id:, fields: %i[id media_url], **params)
61
62
  check_for_auth_token!(params)
@@ -73,7 +74,8 @@ module InstagramBasicDisplay
73
74
  private
74
75
 
75
76
  def make_request(uri, params = {})
76
- uri.query = URI.encode_www_form(params)
77
+ uri.query = consolidate_query_string(uri, params)
78
+
77
79
  response = Net::HTTP.get_response(uri)
78
80
  InstagramBasicDisplay::Response.new(response)
79
81
  end
@@ -89,6 +91,18 @@ module InstagramBasicDisplay
89
91
  "https://graph.instagram.com/#{user_id || 'me'}"
90
92
  end
91
93
 
94
+ def consolidate_query_string(uri, params = {})
95
+ parsed_query_string = uri.query.to_s
96
+ .split('&')
97
+ .map { |pair| pair.split('=') }
98
+ .to_h
99
+
100
+ params = params.transform_keys(&:to_s)
101
+ params = parsed_query_string.merge(params)
102
+
103
+ URI.encode_www_form(params)
104
+ end
105
+
92
106
  attr_reader :configuration
93
107
  end
94
108
  end
@@ -15,6 +15,6 @@
15
15
  # limitations under the License.
16
16
 
17
17
  module InstagramBasicDisplay
18
- VERSION = '0.1.1'
18
+ VERSION = '0.2.0'
19
19
  end
20
20
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instagram_basic_display
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ConvertKit, LLC