bridge_api 0.0.3 → 0.0.5
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/bridge_api/api_array.rb +24 -0
- data/lib/bridge_api/client.rb +0 -1
- data/lib/bridge_api/version.rb +1 -1
- data/spec/bridge_api/client_spec.rb +12 -0
- data/spec/fixtures/users.json +23 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aab44d2529605313129140d8ef6144830e69b20
|
4
|
+
data.tar.gz: 009f3875596e5ddaa7216462f8b605289ce40614
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f0d07ab9e68c9eaa81a07517daf8dc285de353197f47d738b2f413e614956feac06b2a8609ed59b7c569a09819b39c9a07447578502f0e66430a29ae404c510
|
7
|
+
data.tar.gz: bf5cf61588796feb7c1ffd883c2dcce69399d100faf5add8b06be4fc544b9915c926aad07cb346c071eb4aaa41d64284e90bb2466663fa3e322d7ec94c9dd172
|
data/Gemfile.lock
CHANGED
data/lib/bridge_api/api_array.rb
CHANGED
@@ -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)
|
data/lib/bridge_api/client.rb
CHANGED
data/lib/bridge_api/version.rb
CHANGED
@@ -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
|
data/spec/fixtures/users.json
CHANGED
@@ -1,6 +1,27 @@
|
|
1
1
|
{
|
2
|
-
"meta": {
|
3
|
-
|
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.
|
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-
|
11
|
+
date: 2016-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|