bridge_api 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b84f18fee1c0bb65b0fe3254ea67774733e4180
4
- data.tar.gz: 0f674a5ecd51872697e297847d997393f26a22af
3
+ metadata.gz: 5aab44d2529605313129140d8ef6144830e69b20
4
+ data.tar.gz: 009f3875596e5ddaa7216462f8b605289ce40614
5
5
  SHA512:
6
- metadata.gz: 1578c40b762f651464433aa0c6acd422ebd6ca6d0e27419c53d99871ecc5e509c537ebea071a49c95923c438b309e33312df00b834a8361380339f4aa3d5b75e
7
- data.tar.gz: 0e16ae3129d5ddfbcc0aa1b5d1ce569d1aa376c08b2ddbb7dc185e9b73eb944bff333c951a172a51799523e50b75ac5c6faf11ec810bbe5965ace379c41fb589
6
+ metadata.gz: 4f0d07ab9e68c9eaa81a07517daf8dc285de353197f47d738b2f413e614956feac06b2a8609ed59b7c569a09819b39c9a07447578502f0e66430a29ae404c510
7
+ data.tar.gz: bf5cf61588796feb7c1ffd883c2dcce69399d100faf5add8b06be4fc544b9915c926aad07cb346c071eb4aaa41d64284e90bb2466663fa3e322d7ec94c9dd172
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bridge_api (0.0.2)
4
+ bridge_api (0.0.3)
5
5
  faraday (~> 0.9.0)
6
6
  faraday_middleware (~> 0.9.0)
7
7
  footrest (>= 0.5.1)
@@ -5,6 +5,8 @@ module BridgeAPI
5
5
 
6
6
  @next_page = nil
7
7
  @prev_page = nil
8
+ @linked = {}
9
+ @meta = {}
8
10
 
9
11
  META_FIELDS = %w(meta linked).freeze
10
12
 
@@ -43,6 +45,14 @@ module BridgeAPI
43
45
  !@next_page.nil?
44
46
  end
45
47
 
48
+ def meta
49
+ @meta
50
+ end
51
+
52
+ def linked
53
+ @linked
54
+ end
55
+
46
56
  def next_page
47
57
  load_page(@next_page)
48
58
  end
@@ -103,6 +113,20 @@ module BridgeAPI
103
113
  @headers = response.headers
104
114
  @method = response.env[:method]
105
115
  init_pages(response)
116
+ init_linked(response)
117
+ init_meta(response)
118
+ end
119
+
120
+ def init_linked(response)
121
+ if response.body.is_a?(Hash) && response.body.key?('linked')
122
+ @linked = response.body['linked']
123
+ end
124
+ end
125
+
126
+ def init_meta(response)
127
+ if response.body.is_a?(Hash) && response.body.key?('meta')
128
+ @meta = response.body['meta']
129
+ end
106
130
  end
107
131
 
108
132
  def init_pages(response)
@@ -1,7 +1,6 @@
1
1
  require 'footrest/client'
2
2
  require 'faraday'
3
3
  require 'footrest'
4
- require 'byebug'
5
4
  require 'footrest/http_error'
6
5
  require 'footrest/pagination'
7
6
  require 'footrest/follow_redirects'
@@ -1,3 +1,3 @@
1
1
  module BridgeAPI
2
- VERSION = '0.0.3' unless defined?(BridgeAPI::VERSION)
2
+ VERSION = '0.0.5' unless defined?(BridgeAPI::VERSION)
3
3
  end
@@ -11,5 +11,17 @@ describe BridgeAPI::Client do
11
11
  expect(client.connection.headers['Authorization']).to(eq("Bearer test_token"))
12
12
  end
13
13
 
14
+ it 'should set the meta property on client' do
15
+ client = BridgeAPI::Client.new(prefix: "https://www.fake.com", token: "test_token")
16
+ users = client.get_all_users
17
+ expect(users.meta['next']).to(eq('http://bridge.bridgeapp.com/api/author/users?after=eyJ0eXAiOiJKV1QiLCJhSDiQQ'))
18
+ end
19
+
20
+ it 'should set the linked property on client' do
21
+ client = BridgeAPI::Client.new(prefix: "https://www.fake.com", token: "test_token")
22
+ users = client.get_all_users
23
+ expect(users.linked['custom_fields'][0]['id']).to(eq('1'))
24
+ end
25
+
14
26
 
15
27
  end
@@ -1,6 +1,27 @@
1
1
  {
2
- "meta": {},
3
- "linked": {},
2
+ "meta": {
3
+ "next": "http://bridge.bridgeapp.com/api/author/users?after=eyJ0eXAiOiJKV1QiLCJhSDiQQ"
4
+ },
5
+ "linked": {
6
+ "custom_fields": [
7
+ {
8
+ "id": "1",
9
+ "name": "Title"
10
+ }
11
+ ],
12
+ "custom_field_values": [
13
+ {
14
+ "id": "2",
15
+ "value": "Senator",
16
+ "links": {
17
+ "custom_field": {
18
+ "id": "1",
19
+ "type": "custom_fields"
20
+ }
21
+ }
22
+ }
23
+ ]
24
+ },
4
25
  "users": [
5
26
  {
6
27
  "id": "9",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bridge_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jay Shaffer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-28 00:00:00.000000000 Z
11
+ date: 2016-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake