fulcrum 0.6.1 → 0.8.2
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 +5 -5
- data/CHANGELOG.md +12 -0
- data/README.md +72 -3
- data/fulcrum.gemspec +1 -1
- data/lib/fulcrum.rb +4 -0
- data/lib/fulcrum/attachment.rb +46 -0
- data/lib/fulcrum/audit_log.rb +6 -0
- data/lib/fulcrum/authorization.rb +12 -0
- data/lib/fulcrum/client.rb +47 -2
- data/lib/fulcrum/form.rb +7 -0
- 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/data/test.pdf +56 -0
- data/spec/lib/attachment_spec.rb +93 -0
- 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/form_spec.rb +20 -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 +22 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a74d4e0476b8350803713e7372bb9d98a439ece325338a921c7fd36d0bb389e3
|
4
|
+
data.tar.gz: 0d44ecdad6ea4865ab0fc354a4ee62fa11f1ac119f57d6f4342a349393258257
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d6103a9947ba826ed6d6cea1d821fa435e43bb9045db246c9577c921f3ec66360708a485f9179ccac563ba7ed97b3f98acc82ed2ef84367c083675e9808549f
|
7
|
+
data.tar.gz: a63327b930c34b0c07bdcfbc83cf565df9f8aaae74d87e3d5577f6fa5080957988e2ec2f9e6883e57a13ff21957a315bce733a5b83962c597f29e022aba675d2
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## v0.8.0 (February 20, 2020)
|
2
|
+
* Add form history support (#28)
|
3
|
+
|
4
|
+
## v0.7.0 (April 12, 2019)
|
5
|
+
* Add roles support (#20)
|
6
|
+
* Add audit logs support (#13)
|
7
|
+
* Add ability to create, update, and delete projects (#16)
|
8
|
+
* Add record history support (#15)
|
9
|
+
* Add Query API support (#21)
|
10
|
+
* Add authorizations support (#18)
|
11
|
+
* Add users support (#17)
|
12
|
+
|
1
13
|
## v0.6.0
|
2
14
|
* Add format option for fetching media tracks (default: json) (#10)
|
3
15
|
* 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
|
@@ -277,6 +291,22 @@ Format can be 'json', 'geojson', 'gpx', or 'kml'.
|
|
277
291
|
|
278
292
|
|
279
293
|
|
294
|
+
## Attachments
|
295
|
+
|
296
|
+
### client.attachments.all(params = {})
|
297
|
+
|
298
|
+
### client.attachments.find(id)
|
299
|
+
|
300
|
+
### client.attachments.create(file_or_path, attributes = {})
|
301
|
+
|
302
|
+
Suggestion pass a File.open(file) to this as parameter
|
303
|
+
|
304
|
+
### client.attachments.finalize(id)
|
305
|
+
|
306
|
+
### client.attachments.delete(id)
|
307
|
+
|
308
|
+
|
309
|
+
|
280
310
|
## Changesets
|
281
311
|
|
282
312
|
### client.changesets.all(params = {})
|
@@ -305,9 +335,48 @@ Format can be 'json', 'geojson', 'gpx', or 'kml'.
|
|
305
335
|
|
306
336
|
|
307
337
|
|
308
|
-
##
|
338
|
+
## Roles
|
339
|
+
|
340
|
+
### client.roles.all(params = {})
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
## Audit Logs
|
345
|
+
|
346
|
+
### client.audit_logs.all(params = {})
|
347
|
+
|
348
|
+
### client.audit_logs.find(id)
|
349
|
+
|
350
|
+
|
351
|
+
|
352
|
+
## Authorizations
|
353
|
+
|
354
|
+
### client.authorizations.all(params = {})
|
355
|
+
|
356
|
+
### client.authorizations.find(id)
|
357
|
+
|
358
|
+
### client.authorizations.update(id, authorization)
|
359
|
+
|
360
|
+
### client.authorizations.delete(id)
|
361
|
+
|
362
|
+
### client.authorizations.regenerate(id)
|
363
|
+
|
364
|
+
|
365
|
+
|
366
|
+
## Query
|
367
|
+
|
368
|
+
### client.query(sql, format = 'json')
|
369
|
+
|
370
|
+
Fetches a Query API response for various formats for a provided SQL string.
|
371
|
+
|
372
|
+
Format can be 'json', 'csv', or 'geojson'.
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
## Documentation & Examples
|
309
377
|
|
310
|
-
* [Fulcrum API
|
378
|
+
* [Fulcrum REST API](https://learn.fulcrumapp.com/dev/rest/intro)
|
379
|
+
* [Fulcrum Query API](https://learn.fulcrumapp.com/dev/query/intro#examples)
|
311
380
|
|
312
381
|
## Contributing
|
313
382
|
|
data/fulcrum.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.require_paths = ["lib"]
|
17
17
|
gem.version = Fulcrum::VERSION
|
18
18
|
|
19
|
-
gem.add_development_dependency 'rake',
|
19
|
+
gem.add_development_dependency 'rake', ">= 12.3.3"
|
20
20
|
gem.add_development_dependency 'rspec', '~> 3.2', '>= 3.2.0'
|
21
21
|
gem.add_development_dependency 'webmock', '~> 1.12', '>= 1.12.0'
|
22
22
|
|
data/lib/fulcrum.rb
CHANGED
@@ -17,11 +17,15 @@ require 'fulcrum/actions/media_versions'
|
|
17
17
|
require 'fulcrum/actions/gps_track'
|
18
18
|
require 'fulcrum/video'
|
19
19
|
require 'fulcrum/audio'
|
20
|
+
require 'fulcrum/attachment'
|
20
21
|
require 'fulcrum/signature'
|
21
22
|
require 'fulcrum/project'
|
22
23
|
require 'fulcrum/record'
|
23
24
|
require 'fulcrum/layer'
|
24
25
|
require 'fulcrum/changeset'
|
25
26
|
require 'fulcrum/webhook'
|
27
|
+
require 'fulcrum/role'
|
28
|
+
require 'fulcrum/audit_log'
|
29
|
+
require 'fulcrum/authorization'
|
26
30
|
require 'fulcrum/client'
|
27
31
|
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Fulcrum
|
2
|
+
class Attachment < MediaResource
|
3
|
+
include Actions::Delete
|
4
|
+
|
5
|
+
def finalize(id)
|
6
|
+
call(:post, "#{collection}/finalize", {id: id})
|
7
|
+
end
|
8
|
+
|
9
|
+
def collection
|
10
|
+
resources_name
|
11
|
+
end
|
12
|
+
|
13
|
+
def member(id)
|
14
|
+
"#{resources_name}/#{id}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def find(id)
|
18
|
+
call(:get, member(id))
|
19
|
+
end
|
20
|
+
|
21
|
+
def all(params = {})
|
22
|
+
call(:get, collection, params)
|
23
|
+
end
|
24
|
+
|
25
|
+
def create(file, attrs = {})
|
26
|
+
response = call(:post, create_action, attrs)
|
27
|
+
binary_upload(file, response['url'], attrs[:file_size])
|
28
|
+
{ name: attrs[:name], attachment_id: response['id'] }
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def binary_upload(file, url, file_size)
|
34
|
+
connection = Faraday.new(url: url) do |faraday|
|
35
|
+
faraday.request :multipart
|
36
|
+
faraday.adapter :net_http
|
37
|
+
end
|
38
|
+
connection.put do |req|
|
39
|
+
req.headers['Content-Type'] = 'octet/stream'
|
40
|
+
req.headers['Content-Length'] = "#{file_size}"
|
41
|
+
req.headers['Content-Transfer-Encoding'] = 'binary'
|
42
|
+
req.body = Faraday::UploadIO.new(file, 'octet/stream')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
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
|
@@ -97,6 +120,10 @@ module Fulcrum
|
|
97
120
|
@audio ||= Fulcrum::Audio.new(self)
|
98
121
|
end
|
99
122
|
|
123
|
+
def attachments
|
124
|
+
@attachment ||= Fulcrum::Attachment.new(self)
|
125
|
+
end
|
126
|
+
|
100
127
|
def signatures
|
101
128
|
@signatures ||= Fulcrum::Signature.new(self)
|
102
129
|
end
|
@@ -124,5 +151,23 @@ module Fulcrum
|
|
124
151
|
def webhooks
|
125
152
|
@webhooks ||= Fulcrum::Webhook.new(self)
|
126
153
|
end
|
154
|
+
|
155
|
+
def roles
|
156
|
+
@roles ||= Fulcrum::Role.new(self)
|
157
|
+
end
|
158
|
+
|
159
|
+
def audit_logs
|
160
|
+
@audit_logs ||= Fulcrum::AuditLog.new(self)
|
161
|
+
end
|
162
|
+
|
163
|
+
def authorizations
|
164
|
+
@authorizations ||= Fulcrum::Authorization.new(self)
|
165
|
+
end
|
166
|
+
|
167
|
+
def query(sql, format = 'json')
|
168
|
+
body = { q: sql,
|
169
|
+
format: format }
|
170
|
+
call(:post, 'query', body)
|
171
|
+
end
|
127
172
|
end
|
128
173
|
end
|
data/lib/fulcrum/form.rb
CHANGED
data/lib/fulcrum/project.rb
CHANGED
data/lib/fulcrum/record.rb
CHANGED
data/lib/fulcrum/role.rb
ADDED
data/lib/fulcrum/version.rb
CHANGED
data/spec/data/test.pdf
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
%PDF-1.7
|
2
|
+
%����
|
3
|
+
1 0 obj
|
4
|
+
<</Pages 2 0 R /Type/Catalog>>
|
5
|
+
endobj
|
6
|
+
2 0 obj
|
7
|
+
<</Count 2/Kids[ 4 0 R 8 0 R ]/Type/Pages>>
|
8
|
+
endobj
|
9
|
+
3 0 obj
|
10
|
+
<</CreationDate(D:20210803100643)/Creator(PDFium)/Producer(PDFium)>>
|
11
|
+
endobj
|
12
|
+
4 0 obj
|
13
|
+
<</Contents 5 0 R /MediaBox[ 0 0 612 792]/Parent 2 0 R /Resources<</Font<</F1 6 0 R >>/ProcSet 7 0 R >>/Type/Page>>
|
14
|
+
endobj
|
15
|
+
5 0 obj
|
16
|
+
<</Filter/FlateDecode/Length 311>>stream
|
17
|
+
x����j�0����[h������ɡ(��.b�Q��`ɥ��k'$�@�J��;}�β�a�(a�}���EIF�,a�8'.CQ��
|
18
|
+
�����Ryz������9s_S�G��V�sNrNy��r���>�d��hv}nr���A;�T�q ��V� �o�/,��
|
19
|
+
endstream
|
20
|
+
endobj
|
21
|
+
6 0 obj
|
22
|
+
<</BaseFont/Helvetica/Encoding/WinAnsiEncoding/Name/F1/Subtype/Type1/Type/Font>>
|
23
|
+
endobj
|
24
|
+
7 0 obj
|
25
|
+
[/PDF/Text]
|
26
|
+
endobj
|
27
|
+
8 0 obj
|
28
|
+
<</Contents 9 0 R /MediaBox[ 0 0 612 792]/Parent 2 0 R /Resources<</Font<</F1 6 0 R >>/ProcSet 7 0 R >>/Type/Page>>
|
29
|
+
endobj
|
30
|
+
9 0 obj
|
31
|
+
<</Filter/FlateDecode/Length 274>>stream
|
32
|
+
x����j�0����[X�1��+��Bi�^z�k�,E#v߾YE��"%�̐��f�p��^���e
|
33
|
+
V�Z³)n�{�R���&��ۙ�ъ�$7�
|
34
|
+
����?ݠM{�#F;�%!�,Lg���%=֗x�7�$#�y�\�b8�����2r3����z�����
|
35
|
+
endstream
|
36
|
+
endobj
|
37
|
+
xref
|
38
|
+
0 10
|
39
|
+
0000000000 65535 f
|
40
|
+
0000000017 00000 n
|
41
|
+
0000000066 00000 n
|
42
|
+
0000000129 00000 n
|
43
|
+
0000000216 00000 n
|
44
|
+
0000000350 00000 n
|
45
|
+
0000000733 00000 n
|
46
|
+
0000000832 00000 n
|
47
|
+
0000000862 00000 n
|
48
|
+
0000000996 00000 n
|
49
|
+
trailer
|
50
|
+
<<
|
51
|
+
/Root 1 0 R
|
52
|
+
/Info 3 0 R
|
53
|
+
/Size 10/ID[<06CD5B1232D77C2A68B8A7743652C304><06CD5B1232D77C2A68B8A7743652C304>]>>
|
54
|
+
startxref
|
55
|
+
1342
|
56
|
+
%%EOF
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
include Support::ResourceExamples
|
4
|
+
|
5
|
+
describe Fulcrum::Attachment do
|
6
|
+
let(:test_file) { './spec/data/test.pdf' }
|
7
|
+
|
8
|
+
include_context 'with client'
|
9
|
+
include_context 'with media resource'
|
10
|
+
include_context 'with resource parameters'
|
11
|
+
|
12
|
+
let(:resource) { client.attachments }
|
13
|
+
|
14
|
+
include_examples 'finds resource'
|
15
|
+
include_examples 'deletes resource'
|
16
|
+
|
17
|
+
let(:create_url) do
|
18
|
+
"#{client.url}/#{resource.create_action}"
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#all' do
|
22
|
+
let(:list_response) do
|
23
|
+
data = {}
|
24
|
+
data["form_id"] = {}
|
25
|
+
data.to_json
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'lists all attachments' do
|
29
|
+
stub_request(:get, create_url)
|
30
|
+
.to_return(status: 200, body: list_response,
|
31
|
+
headers: {"Content-Type" => "application/json"})
|
32
|
+
|
33
|
+
resources = resource.all
|
34
|
+
|
35
|
+
expect(client.response.status).to eq(200)
|
36
|
+
|
37
|
+
expect(resources).to be_a(Hash)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#create' do
|
42
|
+
let(:ws_url) do
|
43
|
+
'https://fulcrumapp.s3.amazonaws.com/attachments/example'
|
44
|
+
end
|
45
|
+
|
46
|
+
let(:attrs) do
|
47
|
+
{ "name": "Test",
|
48
|
+
"owners": [ {
|
49
|
+
"type": "form",
|
50
|
+
"id": "12345"
|
51
|
+
} ] }
|
52
|
+
end
|
53
|
+
|
54
|
+
let(:response) do
|
55
|
+
data = {}
|
56
|
+
data['url'] = ws_url
|
57
|
+
data['id'] = "123"
|
58
|
+
data.to_json
|
59
|
+
end
|
60
|
+
|
61
|
+
let(:create_parameters) { [ File.open(test_file) , attrs ] }
|
62
|
+
|
63
|
+
it 'creates attachment data' do
|
64
|
+
stub_request(:post, create_url)
|
65
|
+
.with(body: attrs)
|
66
|
+
.to_return(status: 200, body: response,
|
67
|
+
headers: {"Content-Type" => "application/json"})
|
68
|
+
stub_request(:put, ws_url)
|
69
|
+
.to_return(status: 200,
|
70
|
+
headers: {"Content-Type" => "application/json"})
|
71
|
+
|
72
|
+
object = resource.create(*create_parameters)
|
73
|
+
|
74
|
+
expect(client.response.status).to eq(200)
|
75
|
+
|
76
|
+
expect(object[:name]).to eq(attrs[:name])
|
77
|
+
|
78
|
+
expect(object[:attachment_id]).to eq(JSON.parse(response)['id'])
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
describe '#finalize' do
|
83
|
+
it 'finalizes the attachment' do
|
84
|
+
stub_request(:post, "#{create_url}/finalize")
|
85
|
+
.to_return(status: 201,
|
86
|
+
headers: {"Content-Type" => "application/json"})
|
87
|
+
|
88
|
+
object = resource.finalize(resource_id)
|
89
|
+
|
90
|
+
expect(client.response.status).to eq(201)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -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/form_spec.rb
CHANGED
@@ -13,4 +13,24 @@ describe Fulcrum::Form 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}/forms/8ae9115-0430-459e-a1b7-7ac46011e0ce/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('8ae9115-0430-459e-a1b7-7ac46011e0ce')
|
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
|
35
|
+
|
16
36
|
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,35 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fulcrum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fulcrum
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '10.4'
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
19
|
+
version: 12.3.3
|
23
20
|
type: :development
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
26
23
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '10.4'
|
30
24
|
- - ">="
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
26
|
+
version: 12.3.3
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: rspec
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,7 +141,10 @@ files:
|
|
147
141
|
- lib/fulcrum/actions/list.rb
|
148
142
|
- lib/fulcrum/actions/media_versions.rb
|
149
143
|
- lib/fulcrum/actions/update.rb
|
144
|
+
- lib/fulcrum/attachment.rb
|
150
145
|
- lib/fulcrum/audio.rb
|
146
|
+
- lib/fulcrum/audit_log.rb
|
147
|
+
- lib/fulcrum/authorization.rb
|
151
148
|
- lib/fulcrum/changeset.rb
|
152
149
|
- lib/fulcrum/choice_list.rb
|
153
150
|
- lib/fulcrum/classification_set.rb
|
@@ -161,6 +158,7 @@ files:
|
|
161
158
|
- lib/fulcrum/project.rb
|
162
159
|
- lib/fulcrum/record.rb
|
163
160
|
- lib/fulcrum/resource.rb
|
161
|
+
- lib/fulcrum/role.rb
|
164
162
|
- lib/fulcrum/signature.rb
|
165
163
|
- lib/fulcrum/version.rb
|
166
164
|
- lib/fulcrum/video.rb
|
@@ -169,8 +167,12 @@ files:
|
|
169
167
|
- spec/data/test.jpg
|
170
168
|
- spec/data/test.m4a
|
171
169
|
- spec/data/test.mp4
|
170
|
+
- spec/data/test.pdf
|
172
171
|
- spec/data/test.png
|
172
|
+
- spec/lib/attachment_spec.rb
|
173
173
|
- spec/lib/audio_spec.rb
|
174
|
+
- spec/lib/audit_log_spec.rb
|
175
|
+
- spec/lib/authorization_spec.rb
|
174
176
|
- spec/lib/choice_list_spec.rb
|
175
177
|
- spec/lib/classification_set_spec.rb
|
176
178
|
- spec/lib/client_spec.rb
|
@@ -180,6 +182,7 @@ files:
|
|
180
182
|
- spec/lib/photo_spec.rb
|
181
183
|
- spec/lib/project_spec.rb
|
182
184
|
- spec/lib/record_spec.rb
|
185
|
+
- spec/lib/role_spec.rb
|
183
186
|
- spec/lib/signature_spec.rb
|
184
187
|
- spec/lib/video_spec.rb
|
185
188
|
- spec/lib/webhook_spec.rb
|
@@ -189,7 +192,7 @@ homepage: https://github.com/fulcrumapp/fulcrum-ruby
|
|
189
192
|
licenses:
|
190
193
|
- MIT
|
191
194
|
metadata: {}
|
192
|
-
post_install_message:
|
195
|
+
post_install_message:
|
193
196
|
rdoc_options: []
|
194
197
|
require_paths:
|
195
198
|
- lib
|
@@ -204,9 +207,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
207
|
- !ruby/object:Gem::Version
|
205
208
|
version: '0'
|
206
209
|
requirements: []
|
207
|
-
|
208
|
-
|
209
|
-
signing_key:
|
210
|
+
rubygems_version: 3.2.22
|
211
|
+
signing_key:
|
210
212
|
specification_version: 4
|
211
213
|
summary: Fulcrum API client for ruby
|
212
214
|
test_files:
|
@@ -214,8 +216,12 @@ test_files:
|
|
214
216
|
- spec/data/test.jpg
|
215
217
|
- spec/data/test.m4a
|
216
218
|
- spec/data/test.mp4
|
219
|
+
- spec/data/test.pdf
|
217
220
|
- spec/data/test.png
|
221
|
+
- spec/lib/attachment_spec.rb
|
218
222
|
- spec/lib/audio_spec.rb
|
223
|
+
- spec/lib/audit_log_spec.rb
|
224
|
+
- spec/lib/authorization_spec.rb
|
219
225
|
- spec/lib/choice_list_spec.rb
|
220
226
|
- spec/lib/classification_set_spec.rb
|
221
227
|
- spec/lib/client_spec.rb
|
@@ -225,6 +231,7 @@ test_files:
|
|
225
231
|
- spec/lib/photo_spec.rb
|
226
232
|
- spec/lib/project_spec.rb
|
227
233
|
- spec/lib/record_spec.rb
|
234
|
+
- spec/lib/role_spec.rb
|
228
235
|
- spec/lib/signature_spec.rb
|
229
236
|
- spec/lib/video_spec.rb
|
230
237
|
- spec/lib/webhook_spec.rb
|