fulcrum 0.1.6 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/LICENSE +2 -2
- data/README.md +189 -70
- data/Rakefile +5 -0
- data/fulcrum.gemspec +2 -3
- data/lib/fulcrum.rb +22 -14
- data/lib/fulcrum/actions/create.rb +15 -0
- data/lib/fulcrum/actions/delete.rb +12 -0
- data/lib/fulcrum/actions/find.rb +11 -0
- data/lib/fulcrum/actions/list.rb +19 -0
- data/lib/fulcrum/actions/update.rb +11 -0
- data/lib/fulcrum/changeset.rb +12 -0
- data/lib/fulcrum/choice_list.rb +6 -35
- data/lib/fulcrum/classification_set.rb +6 -36
- data/lib/fulcrum/client.rb +120 -0
- data/lib/fulcrum/form.rb +6 -35
- data/lib/fulcrum/layer.rb +6 -0
- data/lib/fulcrum/media_resource.rb +47 -0
- data/lib/fulcrum/membership.rb +5 -0
- data/lib/fulcrum/page.rb +17 -0
- data/lib/fulcrum/photo.rb +9 -29
- data/lib/fulcrum/project.rb +3 -9
- data/lib/fulcrum/record.rb +6 -35
- data/lib/fulcrum/resource.rb +40 -0
- data/lib/fulcrum/signature.rb +15 -0
- data/lib/fulcrum/version.rb +1 -1
- data/lib/fulcrum/video.rb +23 -0
- data/spec/client_helper.rb +9 -0
- data/spec/data/test.jpg +0 -0
- data/spec/data/test.mp4 +0 -0
- data/spec/data/test.png +0 -0
- data/spec/lib/choice_list_spec.rb +10 -115
- data/spec/lib/classification_set_spec.rb +11 -114
- data/spec/lib/client_spec.rb +9 -0
- data/spec/lib/form_spec.rb +10 -111
- data/spec/lib/layer_spec.rb +13 -0
- data/spec/lib/membership_spec.rb +12 -0
- data/spec/lib/photo_spec.rb +9 -88
- data/spec/lib/project_spec.rb +7 -23
- data/spec/lib/record_spec.rb +10 -115
- data/spec/lib/signature_spec.rb +16 -0
- data/spec/lib/video_spec.rb +16 -0
- data/spec/resource_examples.rb +147 -0
- data/spec/spec_helper.rb +2 -0
- metadata +37 -41
- data/.rvmrc +0 -1
- data/lib/fulcrum/api.rb +0 -99
- data/lib/fulcrum/member.rb +0 -16
- data/lib/fulcrum/validators/base_validator.rb +0 -31
- data/lib/fulcrum/validators/choice_list_validator.rb +0 -30
- data/lib/fulcrum/validators/classification_set_validator.rb +0 -38
- data/lib/fulcrum/validators/form_validator.rb +0 -150
- data/lib/fulcrum/validators/record_validator.rb +0 -18
- data/spec/data/form_data.json +0 -175
- data/spec/lib/api_spec.rb +0 -42
- data/spec/lib/member_spec.rb +0 -52
- data/spec/lib/validators/choice_list_validator_spec.rb +0 -73
- data/spec/lib/validators/classification_set_validator_spec.rb +0 -88
- data/spec/lib/validators/form_validator_spec.rb +0 -4
- data/spec/lib/validators/record_validator_spec.rb +0 -53
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWFhOTc0Yzc4YzEzODQ2ZjE5MWVmMDI3NDc5MmU1Yjg1MDA3NzY1NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NDIyNjg1Yzg0MzMwNDFmNThiMTgyNjM1MWNkNzkyMmZhZjkxYWQwNw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OGYxYjYxYWEzMWMwNWNhYTJhMWZiZjUyMTZhYzZlZjlhZGE2MjY3MGZlYTE2
|
10
|
+
MmY3ZjNiYjgzM2FmYTVmMGIzODliMzhmMzM0Yzg3NGY1MTIzYjA0YjIzZTdj
|
11
|
+
MWNkNGE5NzE1MDhhZGZmZTIzNjFhMzc1MTNjYWIzYzRhOGY3Y2I=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWYzNGE3NGUyZWNiMjBlMzY1MGJmMzE2MGZmYjVkZGYwN2YxODhjMjk5MWI3
|
14
|
+
OTk0NWQyMzNiNzcyMjQwOWNmYzkzMmMyNTI2Mzk4MjAzNGIyMTBmZTdjNzVj
|
15
|
+
NDg4NzMzNDU3YzBkYmQ5ZGY2NjE1M2NhMTE2YjAyMTdlMDRjNzM=
|
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c)
|
1
|
+
Copyright (c) 2014 Spatial Networks
|
2
2
|
|
3
3
|
MIT License
|
4
4
|
|
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ Fulcrum API Gem
|
|
5
5
|
## Requirements
|
6
6
|
|
7
7
|
* Ruby 1.9
|
8
|
-
* [Fulcrum
|
8
|
+
* [Fulcrum account](https://web.fulcrumapp.com)
|
9
9
|
|
10
10
|
## Installation
|
11
11
|
|
@@ -23,118 +23,237 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
gem install fulcrum
|
25
25
|
|
26
|
-
##
|
26
|
+
## Using the gem
|
27
27
|
|
28
|
-
|
29
|
-
Fulcrum::Api.configure do |config|
|
30
|
-
config.uri = 'https://api.fulcrumapp.com/api/v2'
|
31
|
-
config.key = 'your_api_key'
|
32
|
-
end
|
33
|
-
```
|
28
|
+
## Client
|
34
29
|
|
35
|
-
|
30
|
+
All interaction with the API is done through a client object. Below is a simple example of how to instantiate a client object.
|
36
31
|
|
37
32
|
```ruby
|
38
|
-
Fulcrum::
|
39
|
-
# opts = { 'page' => page_number,
|
40
|
-
# 'updated_since' => date_time }
|
33
|
+
client = Fulcrum::Client.new(your_api_key)
|
41
34
|
```
|
42
35
|
|
43
|
-
## Forms
|
44
36
|
|
45
|
-
|
46
|
-
Fulcrum::Form.all(opts)
|
47
|
-
# opts = { 'page' => page_number,
|
48
|
-
# 'schema' => true_or_false }
|
37
|
+
## Basics
|
49
38
|
|
50
|
-
Fulcrum
|
51
|
-
# opts = { 'include_foreign_elements' => true_or_false }
|
39
|
+
In general, this API is intended to be a low level wrapper around the Fulcrum API. All of the filtering and query parameters are passed directly through to the HTTP request. It's best to read the [API documentation](http://fulcrumapp.com/developers/api/) to get a sense of the parameters available for each resource. Resource instances are returned from the API as simple hashes.
|
52
40
|
|
53
|
-
|
54
|
-
# form = { 'form' => { ... } }
|
41
|
+
When using the `create` or `update` methods on resources, the object passed to the method should be in the same format as a result from calling `find` on that resource. For example, you can call `client.records.find(id)` and the result can be used as the parameter for `client.records.update(id, record)`.
|
55
42
|
|
56
|
-
|
57
|
-
|
43
|
+
Each of the API resources has an `all` method that can be used to fetch a list of resources. The `all` methods accept some basic pagination parameters (`per_page` and `page`) you can use to iterate over the pages. Because the index API's are paginated, the result of `all` is not the objects themselves. The `all` methods return a `Page` object that has some basic attributes to inspect the pagination extents. The `objects` attribute returns the actual array of objects. Below is a simple example that fetches the first page of records from the API.
|
44
|
+
```ruby
|
58
45
|
|
59
|
-
Fulcrum::
|
46
|
+
client = Fulcrum::Client.new(your_api_key)
|
47
|
+
|
48
|
+
result = client.records.all(form_id: my_form_id, page: 1, per_page: 100)
|
49
|
+
|
50
|
+
puts result.class # Fulcrum::Page
|
51
|
+
puts result.per_page # => 100
|
52
|
+
puts result.current_page # => 1
|
53
|
+
puts result.total_pages # => 2
|
54
|
+
puts result.total_count # => 137
|
55
|
+
puts result.objects.count # => 100
|
56
|
+
puts result.objects # [ ... the records ... ]
|
60
57
|
```
|
61
58
|
|
62
59
|
## Records
|
63
60
|
|
61
|
+
### client.records.all(params = {})
|
62
|
+
|
63
|
+
Retrieve records with optional parameters. For a full list of the available parameters, see the [API documentation](http://fulcrumapp.com/developers/api/records/).
|
64
|
+
|
64
65
|
```ruby
|
65
|
-
|
66
|
-
|
67
|
-
# 'form_id' => form_id,
|
68
|
-
# 'bounding_box' => 'lat_bottom,lng_left,lat_top,lng_right',
|
69
|
-
# 'updated_since' => date_since_epoch_in_seconds }
|
66
|
+
client.records.all(page: 1, per_page: 100, form_id: some_form_id, updated_since: timestamp)
|
67
|
+
```
|
70
68
|
|
71
|
-
|
72
|
-
Fulcrum::Record.create(record)
|
73
|
-
# record = { 'record' => { ... } }
|
69
|
+
### client.records.find(id)
|
74
70
|
|
75
|
-
|
76
|
-
# record = { 'record' => { ... } }
|
71
|
+
Find a single record by its `id` and return a `Hash` of the record attributes.
|
77
72
|
|
78
|
-
|
79
|
-
```
|
73
|
+
### client.records.create(record)
|
80
74
|
|
81
|
-
|
75
|
+
Create a new record from a `Hash` of attributes. The format of the attributes is identical to the format returned from `find`. The [record API documentation](http://fulcrumapp.com/developers/api/records) has more information on the format. **Note:** although the raw API uses a hash wrapped in a `record` attribute, this is not necessary for the ruby API. Instead of `{ "record" => record_attributes }`, you simply pass `record_attributes` directly to this method.
|
82
76
|
|
83
|
-
|
84
|
-
Fulcrum::Photo.find(access_key, opts)
|
85
|
-
# opts = { 'format' => 'json|jpg' }, defaults to 'json'
|
77
|
+
### client.records.update(id, record)
|
86
78
|
|
87
|
-
|
88
|
-
|
79
|
+
Update an existing record by its `id` using a `Hash` of attributes. The format of the attributes is identical to the format returned from `find`. The [record API documentation](http://fulcrumapp.com/developers/api/records) has more information on the format. **Note:** although the raw API uses a hash wrapped in a `record` attribute, this is not necessary for the ruby API. Instead of `{ "record" => record_attributes }`, you simply pass `record_attributes` directly to this method.
|
80
|
+
|
81
|
+
### client.records.delete(id)
|
82
|
+
|
83
|
+
Delete a record by its `id`.
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
## Forms
|
88
|
+
|
89
|
+
### client.forms.all(params = {})
|
90
|
+
|
91
|
+
### client.forms.find(id)
|
92
|
+
|
93
|
+
### client.forms.create(form)
|
94
|
+
|
95
|
+
### client.forms.update(id, form)
|
96
|
+
|
97
|
+
### client.forms.delete(id)
|
89
98
|
|
90
|
-
Fulcrum::Photo.create(photo, content_type, unique_id, label)
|
91
99
|
|
92
|
-
Fulcrum::Photo.delete(access_key)
|
93
|
-
```
|
94
100
|
|
95
101
|
## Choice Lists
|
96
102
|
|
97
|
-
|
98
|
-
Fulcrum::ChoiceList.all(opts)
|
99
|
-
# opts = { 'page' => page_number }
|
103
|
+
### client.choice_lists.all(params = {})
|
100
104
|
|
101
|
-
|
105
|
+
### client.choice_lists.find(id)
|
102
106
|
|
103
|
-
|
104
|
-
|
107
|
+
### client.choice_lists.create(choice_list)
|
108
|
+
|
109
|
+
### client.choice_lists.update(id, choice_list)
|
110
|
+
|
111
|
+
### client.choice_lists.delete(id)
|
105
112
|
|
106
|
-
Fulcrum::ChoiceList.update(id, choice_list)
|
107
|
-
# choice_list = { 'choice_list' => { ... } }
|
108
113
|
|
109
|
-
Fulcrum::ChoiceList.delete(id)
|
110
|
-
```
|
111
114
|
|
112
115
|
## Classification Sets
|
113
116
|
|
114
|
-
|
115
|
-
Fulcrum::ClassificationSet.all(opts)
|
116
|
-
# opts = { 'page' => page_number }
|
117
|
+
### client.classification_sets.all(params = {})
|
117
118
|
|
118
|
-
|
119
|
+
### client.classification_sets.find(id)
|
119
120
|
|
120
|
-
|
121
|
-
# classification_set = { 'classification_set' => { ... } }
|
121
|
+
### client.classification_sets.create(classification_set)
|
122
122
|
|
123
|
-
|
124
|
-
# classification_set = { 'classification_set' => { ... } }
|
123
|
+
### client.classification_sets.update(id, classification_set)
|
125
124
|
|
126
|
-
|
127
|
-
```
|
125
|
+
### client.classification_sets.delete(id)
|
128
126
|
|
129
|
-
## Members
|
130
127
|
|
131
|
-
```ruby
|
132
|
-
Fulcrum::Member.all(opts)
|
133
|
-
# opts = { 'page' => page_number }
|
134
128
|
|
135
|
-
|
129
|
+
## Projects
|
130
|
+
|
131
|
+
### client.projects.all(params = {})
|
132
|
+
|
133
|
+
### client.projects.find(id)
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
## Layers
|
138
|
+
|
139
|
+
### client.layers.all(params = {})
|
140
|
+
|
141
|
+
### client.layers.find(id)
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
## Photos
|
146
|
+
|
147
|
+
### client.photos.all(params = {})
|
148
|
+
|
149
|
+
### client.photos.find(id)
|
150
|
+
|
151
|
+
### client.photos.create(file_or_path, content_type = 'image/jpeg', attributes = {})
|
152
|
+
|
153
|
+
Create a new photo from a file or a file path. `attributes` must be a `Hash` and currently only accepts 1 attribute, `access_key`.
|
154
|
+
If you specify an `access_key`, it must be a UUID. If you don't specify an `access_key`, one will be automatically generated and returned in the response.
|
155
|
+
|
156
|
+
### client.photos.delete(id)
|
157
|
+
|
158
|
+
### client.photos.original(id) {|io| block }
|
159
|
+
|
160
|
+
Downloads the original version and yields an IO object to the block. The block is passed an IO object that you can call `#read` on. For example, to download a photo to a file:
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
client.photos.original(id) do |input|
|
164
|
+
File.open('output.jpg', 'wb') do |output|
|
165
|
+
output.write(input.read)
|
166
|
+
end
|
167
|
+
end
|
136
168
|
```
|
137
169
|
|
170
|
+
### client.photos.thumbnail(id) {|io| block }
|
171
|
+
|
172
|
+
Downloads the thumbnail version and yields an IO object to the block.
|
173
|
+
|
174
|
+
### client.photos.large(id) {|io| block }
|
175
|
+
|
176
|
+
Downloads the large version and yields an IO object to the block.
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
## Signatures
|
181
|
+
|
182
|
+
### client.signatures.all(params = {})
|
183
|
+
|
184
|
+
### client.signatures.find(id)
|
185
|
+
|
186
|
+
### client.signatures.create(file_or_path, content_type = 'image/png', attributes = {})
|
187
|
+
|
188
|
+
Create a new signature from a file or a file path. `attributes` must be a `Hash` and currently only accepts 1 attribute, `access_key`.
|
189
|
+
If you specify an `access_key`, it must be a UUID. If you don't specify an `access_key`, one will be automatically generated and returned in the response.
|
190
|
+
|
191
|
+
### client.signatures.delete(id)
|
192
|
+
|
193
|
+
### client.signatures.original(id) {|io| block }
|
194
|
+
|
195
|
+
Downloads the original version and yields an IO object to the block.
|
196
|
+
|
197
|
+
### client.signatures.thumbnail(id) {|io| block }
|
198
|
+
|
199
|
+
Downloads the thumbnail version and yields an IO object to the block.
|
200
|
+
|
201
|
+
### client.signatures.large(id) {|io| block }
|
202
|
+
|
203
|
+
Downloads the large version and yields an IO object to the block.
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
## Videos
|
208
|
+
|
209
|
+
### client.videos.all(params = {})
|
210
|
+
|
211
|
+
### client.videos.find(id)
|
212
|
+
|
213
|
+
### client.videos.create(file_or_path, content_type = 'video/mp4', attributes = {})
|
214
|
+
|
215
|
+
Create a new video from a file or a file path. `attributes` must be a `Hash` and currently only accepts 2 attributes, `access_key` and `track`.
|
216
|
+
If you specify an `access_key`, it must be a UUID. If you don't specify an `access_key`, one will be automatically generated and returned in the response.
|
217
|
+
|
218
|
+
### client.videos.delete(id)
|
219
|
+
|
220
|
+
### client.videos.original(id) {|io| block }
|
221
|
+
|
222
|
+
Downloads the original version and yields an IO object to the block.
|
223
|
+
|
224
|
+
### client.videos.small(id) {|io| block }
|
225
|
+
|
226
|
+
Downloads the small version and yields an IO object to the block.
|
227
|
+
|
228
|
+
### client.videos.medium(id) {|io| block }
|
229
|
+
|
230
|
+
Downloads the medium version and yields an IO object to the block.
|
231
|
+
|
232
|
+
### client.videos.track(id)
|
233
|
+
|
234
|
+
Fetches the GPS track for the specified video.
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
## Memberships
|
239
|
+
|
240
|
+
### client.memberships.all(params = {})
|
241
|
+
|
242
|
+
|
243
|
+
|
244
|
+
## Changesets
|
245
|
+
|
246
|
+
### client.changesets.all(params = {})
|
247
|
+
|
248
|
+
### client.changesets.find(id)
|
249
|
+
|
250
|
+
### client.changesets.create(changeset)
|
251
|
+
|
252
|
+
### client.changesets.update(id, changeset)
|
253
|
+
|
254
|
+
### client.changesets.close(id, changeset = {})
|
255
|
+
|
256
|
+
|
138
257
|
## Extra Reading
|
139
258
|
|
140
259
|
* [Fulcrum API documentation](http://fulcrumapp.com/developers/api/)
|
data/Rakefile
CHANGED
data/fulcrum.gemspec
CHANGED
@@ -5,7 +5,7 @@ Gem::Specification.new do |gem|
|
|
5
5
|
gem.authors = ["Spatial Networks"]
|
6
6
|
gem.email = ["sniadmin@spatialnetworks.com"]
|
7
7
|
gem.description = %q{Fulcrum API}
|
8
|
-
gem.summary = %q{Fulcrum API}
|
8
|
+
gem.summary = %q{Fulcrum API client for ruby}
|
9
9
|
gem.homepage = "http://github.com/spatialnetworks/fulcrum-ruby"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
@@ -21,7 +21,6 @@ Gem::Specification.new do |gem|
|
|
21
21
|
gem.add_development_dependency 'debugger'
|
22
22
|
|
23
23
|
gem.add_dependency 'activesupport'
|
24
|
-
gem.add_dependency 'faraday', '~> 0.
|
25
|
-
gem.add_dependency 'hashie'
|
24
|
+
gem.add_dependency 'faraday', '~> 0.9.0'
|
26
25
|
gem.add_dependency 'faraday_middleware'
|
27
26
|
end
|
data/lib/fulcrum.rb
CHANGED
@@ -1,14 +1,22 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
1
|
+
require 'active_support/all'
|
2
|
+
require 'fulcrum/version'
|
3
|
+
require 'fulcrum/resource'
|
4
|
+
require 'fulcrum/actions/list'
|
5
|
+
require 'fulcrum/actions/find'
|
6
|
+
require 'fulcrum/actions/create'
|
7
|
+
require 'fulcrum/actions/update'
|
8
|
+
require 'fulcrum/actions/delete'
|
9
|
+
require 'fulcrum/media_resource'
|
10
|
+
require 'fulcrum/page'
|
11
|
+
require 'fulcrum/choice_list'
|
12
|
+
require 'fulcrum/classification_set'
|
13
|
+
require 'fulcrum/form'
|
14
|
+
require 'fulcrum/membership'
|
15
|
+
require 'fulcrum/photo'
|
16
|
+
require 'fulcrum/video'
|
17
|
+
require 'fulcrum/signature'
|
18
|
+
require 'fulcrum/project'
|
19
|
+
require 'fulcrum/record'
|
20
|
+
require 'fulcrum/layer'
|
21
|
+
require 'fulcrum/changeset'
|
22
|
+
require 'fulcrum/client'
|