fulcrum 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/README.md +53 -1
- data/lib/fulcrum.rb +3 -0
- data/lib/fulcrum/audit_log.rb +6 -0
- data/lib/fulcrum/authorization.rb +12 -0
- data/lib/fulcrum/client.rb +43 -2
- data/lib/fulcrum/project.rb +3 -0
- data/lib/fulcrum/record.rb +6 -0
- data/lib/fulcrum/role.rb +5 -0
- data/lib/fulcrum/version.rb +1 -1
- data/spec/lib/audit_log_spec.rb +13 -0
- data/spec/lib/authorization_spec.rb +15 -0
- data/spec/lib/client_spec.rb +46 -0
- data/spec/lib/project_spec.rb +3 -0
- data/spec/lib/record_spec.rb +19 -0
- data/spec/lib/role_spec.rb +12 -0
- metadata +12 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e9e353e52485fa1f980302440b23986368b8b88
|
4
|
+
data.tar.gz: c0f212bc29ecb2ca29cc603a21c96ddfb09574be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1ebf6988865e7947127983f4c856c900c983962f9015a93036d4b97bc7286f80eb5c65e2b7ef2739b253c63896ca35e93c977e947297e7ffe0fc00f029a70da
|
7
|
+
data.tar.gz: 4c36ddb729622e26344547219173b298d5997f44fd479c5825a1de0423598b66f7280f7f8168c9be21db09945099469096e6601188105838e836416c0965c9c6
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## vTBD
|
2
|
+
* Add roles support (#20)
|
3
|
+
* Add audit logs support (#13)
|
4
|
+
* Add ability to create, update, and delete projects (#16)
|
5
|
+
* Add record history support (#15)
|
6
|
+
* Add Query API support (#21)
|
7
|
+
* Add authorizations support (#18)
|
8
|
+
* Add users support (#17)
|
9
|
+
|
1
10
|
## v0.6.0
|
2
11
|
* Add format option for fetching media tracks (default: json) (#10)
|
3
12
|
* Lower ActiveSupport dependency to 4.1.x (#12)
|
data/README.md
CHANGED
@@ -28,12 +28,22 @@ Or install it yourself as:
|
|
28
28
|
|
29
29
|
## Client
|
30
30
|
|
31
|
-
|
31
|
+
Most interaction with the API is done through a client object. Below is a simple example of how to instantiate a client object.
|
32
32
|
|
33
33
|
```ruby
|
34
34
|
client = Fulcrum::Client.new(your_api_key)
|
35
35
|
```
|
36
36
|
|
37
|
+
A client object assumes you have an API key. To get an API key use the `get_user` and `create_authorization` class methods.
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
Fulcrum::Client.get_user(email, password)
|
41
|
+
# returns a user's name, email, avatar url, and a list of organizations with ids for creating authorizations
|
42
|
+
|
43
|
+
Fulcrum::Client.create_authorization(email, password, org_id, note, timeout = nil, user_id = nil)
|
44
|
+
# creates an authorization for yourself or another user in the provided organization id
|
45
|
+
```
|
46
|
+
|
37
47
|
|
38
48
|
## Basics
|
39
49
|
|
@@ -83,6 +93,10 @@ Update an existing record by its `id` using a `Hash` of attributes. The format o
|
|
83
93
|
|
84
94
|
Delete a record by its `id`. This method optionally accepts a `changeset_id` to group deletes into a Changeset for compatibility with the activity feed.
|
85
95
|
|
96
|
+
### client.records.find(id)
|
97
|
+
|
98
|
+
Find a record's history by its `id`.
|
99
|
+
|
86
100
|
|
87
101
|
|
88
102
|
## Forms
|
@@ -305,6 +319,44 @@ Format can be 'json', 'geojson', 'gpx', or 'kml'.
|
|
305
319
|
|
306
320
|
|
307
321
|
|
322
|
+
## Roles
|
323
|
+
|
324
|
+
### client.roles.all(params = {})
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
## Audit Logs
|
329
|
+
|
330
|
+
### client.audit_logs.all(params = {})
|
331
|
+
|
332
|
+
### client.audit_logs.find(id)
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
## Authorizations
|
337
|
+
|
338
|
+
### client.authorizations.all(params = {})
|
339
|
+
|
340
|
+
### client.authorizations.find(id)
|
341
|
+
|
342
|
+
### client.authorizations.update(id, authorization)
|
343
|
+
|
344
|
+
### client.authorizations.delete(id)
|
345
|
+
|
346
|
+
### client.authorizations.regenerate(id)
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
## Query
|
351
|
+
|
352
|
+
### client.query(sql, format = 'json')
|
353
|
+
|
354
|
+
Fetches a Query API response for various formats for a provided SQL string.
|
355
|
+
|
356
|
+
Format can be 'json', 'csv', or 'geojson'.
|
357
|
+
|
358
|
+
|
359
|
+
|
308
360
|
## Extra Reading
|
309
361
|
|
310
362
|
* [Fulcrum API documentation](http://fulcrumapp.com/developers/api/)
|
data/lib/fulcrum.rb
CHANGED
data/lib/fulcrum/client.rb
CHANGED
@@ -52,11 +52,34 @@ module Fulcrum
|
|
52
52
|
|
53
53
|
resp.body['user']['contexts'].map do |context|
|
54
54
|
{ id: context['id'],
|
55
|
-
name: context['name']
|
56
|
-
token: context['api_token'] }
|
55
|
+
name: context['name'] }
|
57
56
|
end
|
58
57
|
end
|
59
58
|
|
59
|
+
def self.get_user(username, password, url=DEFAULT_URL)
|
60
|
+
connection = create_connection(url)
|
61
|
+
|
62
|
+
connection.basic_auth(username, password)
|
63
|
+
|
64
|
+
resp = connection.get('users.json')
|
65
|
+
user = resp.body['user']
|
66
|
+
user['contexts'] = user['contexts'].map{|c| c.except!('api_token')}
|
67
|
+
|
68
|
+
user
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.create_authorization(username, password, organization_id, note, timeout = nil, user_id = nil, url=DEFAULT_URL)
|
72
|
+
connection = create_connection(url)
|
73
|
+
|
74
|
+
connection.basic_auth(username, password)
|
75
|
+
|
76
|
+
body = { authorization: { organization_id: organization_id,
|
77
|
+
note: note, timeout: timeout, user_id: user_id } }
|
78
|
+
resp = connection.post('authorizations.json', body)
|
79
|
+
|
80
|
+
resp.body['authorization']
|
81
|
+
end
|
82
|
+
|
60
83
|
def self.create_connection(url, key = nil)
|
61
84
|
Faraday.new(url) do |connection|
|
62
85
|
connection.request :multipart
|
@@ -124,5 +147,23 @@ module Fulcrum
|
|
124
147
|
def webhooks
|
125
148
|
@webhooks ||= Fulcrum::Webhook.new(self)
|
126
149
|
end
|
150
|
+
|
151
|
+
def roles
|
152
|
+
@roles ||= Fulcrum::Role.new(self)
|
153
|
+
end
|
154
|
+
|
155
|
+
def audit_logs
|
156
|
+
@audit_logs ||= Fulcrum::AuditLog.new(self)
|
157
|
+
end
|
158
|
+
|
159
|
+
def authorizations
|
160
|
+
@authorizations ||= Fulcrum::Authorization.new(self)
|
161
|
+
end
|
162
|
+
|
163
|
+
def query(sql, format = 'json')
|
164
|
+
body = { q: sql,
|
165
|
+
format: format }
|
166
|
+
call(:post, 'query', body)
|
167
|
+
end
|
127
168
|
end
|
128
169
|
end
|
data/lib/fulcrum/project.rb
CHANGED
data/lib/fulcrum/record.rb
CHANGED
data/lib/fulcrum/role.rb
ADDED
data/lib/fulcrum/version.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Support::ResourceExamples
|
4
|
+
|
5
|
+
describe Fulcrum::AuditLog do
|
6
|
+
include_context 'with client'
|
7
|
+
include_context 'with resource'
|
8
|
+
|
9
|
+
let(:resource) { client.audit_logs }
|
10
|
+
|
11
|
+
include_examples 'lists resource'
|
12
|
+
include_examples 'finds resource'
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Support::ResourceExamples
|
4
|
+
|
5
|
+
describe Fulcrum::Authorization do
|
6
|
+
include_context 'with client'
|
7
|
+
include_context 'with resource'
|
8
|
+
|
9
|
+
let(:resource) { client.authorizations }
|
10
|
+
|
11
|
+
include_examples 'lists resource'
|
12
|
+
include_examples 'finds resource'
|
13
|
+
include_examples 'updates resource'
|
14
|
+
include_examples 'deletes resource'
|
15
|
+
end
|
data/spec/lib/client_spec.rb
CHANGED
@@ -6,4 +6,50 @@ describe Fulcrum::Client do
|
|
6
6
|
it 'has a default url' do
|
7
7
|
expect(client.url).to eq(Fulcrum::Client::DEFAULT_URL)
|
8
8
|
end
|
9
|
+
|
10
|
+
it 'can query' do
|
11
|
+
url = "#{client.url}/query"
|
12
|
+
response = 'audio,system,,,,,'
|
13
|
+
|
14
|
+
stub_request(:post, url)
|
15
|
+
.with(body: '{"q":"select name from tables limit 1;","format":"csv"}')
|
16
|
+
.to_return(status: 200, body: response,
|
17
|
+
headers: {"Content-Type" => "text/plain"})
|
18
|
+
|
19
|
+
sql = 'select name from tables limit 1;'
|
20
|
+
csv = client.query(sql, 'csv')
|
21
|
+
|
22
|
+
expect(csv).to eq(response)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'can get_user' do
|
26
|
+
url = 'https://fred%40flinstones.com:secret@api.fulcrumapp.com/api/v2/users.json'
|
27
|
+
response = '{"user":{"first_name":"Jason","last_name":"Sanford","email":"jason@fulcrumapp.com","image_small":"https://fulcrumapp-dev.s3.amazonaws.com/user-images/small_abc.jpg","image_large":"https://fulcrumapp-dev.s3.amazonaws.com/user-images/large_abc.jpg","id":"49d06ce5-1457-476c-9cb4-fd9d41ea43ef","contexts":[{"name":"Team Jason","id":"e09c1a03-819d-47d6-aebc-f8712d292b57","api_token":"abc123","image_small":"https://fulcrumapp-dev.s3.amazonaws.com/organization-images/small_abc.jpg","image_large":"https://fulcrumapp-dev.s3.amazonaws.com/organization-images/large_abc.jpg","type":"organization","role":{},"domain":null,"plan":{}}],"access":{"allowed":true}}}'
|
28
|
+
|
29
|
+
stub_request(:get, url)
|
30
|
+
.to_return(status: 200, body: response,
|
31
|
+
headers: {"Content-Type" => "application/json"})
|
32
|
+
|
33
|
+
sql = 'select name from tables limit 1;'
|
34
|
+
user = Fulcrum::Client.get_user('fred@flinstones.com', 'secret')
|
35
|
+
|
36
|
+
expect(user['contexts'].length).to eq(1)
|
37
|
+
expect(user['contexts'][0]['id']).to eq('e09c1a03-819d-47d6-aebc-f8712d292b57')
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'can create_authorization' do
|
41
|
+
url = 'https://fred%40flinstones.com:secret@api.fulcrumapp.com/api/v2/authorizations.json'
|
42
|
+
body = '{"authorization":{"organization_id":"abc-123","note":"Tess Ting","timeout":null,"user_id":null}}'
|
43
|
+
response = '{"authorization":{"note":"Tess Ting","expires_at":null,"timeout":null,"token_last_8":"46c5cb33","last_ip_address":null,"last_user_agent":null,"token":"ac493349cd4de0c376185c1d347d24ce5a3867bd3e04397bb875ed6b9b0546b768caa3bf46c5cb33","created_at":"2019-04-12T13:25:28Z","updated_at":"2019-04-12T13:25:28Z","id":"f1d84caa-da28-4fc5-a341-44bb9efa6266","last_used_at":null,"user_id":"4f1cfa091441405373000443"}}'
|
44
|
+
|
45
|
+
stub_request(:post, url)
|
46
|
+
.with(body: body)
|
47
|
+
.to_return(status: 200, body: response,
|
48
|
+
headers: {"Content-Type" => "application/json"})
|
49
|
+
|
50
|
+
authorization = Fulcrum::Client.create_authorization('fred@flinstones.com', 'secret', 'abc-123', 'Tess Ting')
|
51
|
+
|
52
|
+
expect(authorization['note']).to eq('Tess Ting')
|
53
|
+
expect(authorization['token_last_8']).to eq('46c5cb33')
|
54
|
+
end
|
9
55
|
end
|
data/spec/lib/project_spec.rb
CHANGED
data/spec/lib/record_spec.rb
CHANGED
@@ -13,4 +13,23 @@ describe Fulcrum::Record do
|
|
13
13
|
include_examples 'creates resource'
|
14
14
|
include_examples 'updates resource'
|
15
15
|
include_examples 'deletes resource'
|
16
|
+
|
17
|
+
it 'lists all resources' do
|
18
|
+
url = "#{client.url}/records/abc-123/history.json"
|
19
|
+
|
20
|
+
stub_request(:get, url)
|
21
|
+
.to_return(status: 200, body: list_response,
|
22
|
+
headers: {"Content-Type" => "application/json"})
|
23
|
+
|
24
|
+
page = resource.history('abc-123')
|
25
|
+
|
26
|
+
expect(client.response.status).to eq(200)
|
27
|
+
|
28
|
+
expect(page).to respond_to(:current_page)
|
29
|
+
expect(page).to respond_to(:total_pages)
|
30
|
+
expect(page).to respond_to(:total_count)
|
31
|
+
expect(page).to respond_to(:per_page)
|
32
|
+
|
33
|
+
expect(page.objects).to be_a(Array)
|
34
|
+
end
|
16
35
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fulcrum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fulcrum
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -148,6 +148,8 @@ files:
|
|
148
148
|
- lib/fulcrum/actions/media_versions.rb
|
149
149
|
- lib/fulcrum/actions/update.rb
|
150
150
|
- lib/fulcrum/audio.rb
|
151
|
+
- lib/fulcrum/audit_log.rb
|
152
|
+
- lib/fulcrum/authorization.rb
|
151
153
|
- lib/fulcrum/changeset.rb
|
152
154
|
- lib/fulcrum/choice_list.rb
|
153
155
|
- lib/fulcrum/classification_set.rb
|
@@ -161,6 +163,7 @@ files:
|
|
161
163
|
- lib/fulcrum/project.rb
|
162
164
|
- lib/fulcrum/record.rb
|
163
165
|
- lib/fulcrum/resource.rb
|
166
|
+
- lib/fulcrum/role.rb
|
164
167
|
- lib/fulcrum/signature.rb
|
165
168
|
- lib/fulcrum/version.rb
|
166
169
|
- lib/fulcrum/video.rb
|
@@ -171,6 +174,8 @@ files:
|
|
171
174
|
- spec/data/test.mp4
|
172
175
|
- spec/data/test.png
|
173
176
|
- spec/lib/audio_spec.rb
|
177
|
+
- spec/lib/audit_log_spec.rb
|
178
|
+
- spec/lib/authorization_spec.rb
|
174
179
|
- spec/lib/choice_list_spec.rb
|
175
180
|
- spec/lib/classification_set_spec.rb
|
176
181
|
- spec/lib/client_spec.rb
|
@@ -180,6 +185,7 @@ files:
|
|
180
185
|
- spec/lib/photo_spec.rb
|
181
186
|
- spec/lib/project_spec.rb
|
182
187
|
- spec/lib/record_spec.rb
|
188
|
+
- spec/lib/role_spec.rb
|
183
189
|
- spec/lib/signature_spec.rb
|
184
190
|
- spec/lib/video_spec.rb
|
185
191
|
- spec/lib/webhook_spec.rb
|
@@ -205,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
205
211
|
version: '0'
|
206
212
|
requirements: []
|
207
213
|
rubyforge_project:
|
208
|
-
rubygems_version: 2.
|
214
|
+
rubygems_version: 2.5.2.3
|
209
215
|
signing_key:
|
210
216
|
specification_version: 4
|
211
217
|
summary: Fulcrum API client for ruby
|
@@ -216,6 +222,8 @@ test_files:
|
|
216
222
|
- spec/data/test.mp4
|
217
223
|
- spec/data/test.png
|
218
224
|
- spec/lib/audio_spec.rb
|
225
|
+
- spec/lib/audit_log_spec.rb
|
226
|
+
- spec/lib/authorization_spec.rb
|
219
227
|
- spec/lib/choice_list_spec.rb
|
220
228
|
- spec/lib/classification_set_spec.rb
|
221
229
|
- spec/lib/client_spec.rb
|
@@ -225,6 +233,7 @@ test_files:
|
|
225
233
|
- spec/lib/photo_spec.rb
|
226
234
|
- spec/lib/project_spec.rb
|
227
235
|
- spec/lib/record_spec.rb
|
236
|
+
- spec/lib/role_spec.rb
|
228
237
|
- spec/lib/signature_spec.rb
|
229
238
|
- spec/lib/video_spec.rb
|
230
239
|
- spec/lib/webhook_spec.rb
|