cropio-ruby 0.18 → 0.31
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/README.md +5 -0
- data/lib/cropio/connection/proxiable.rb +16 -3
- data/lib/cropio/resource/base.rb +7 -0
- data/lib/cropio/resources/fuel_hourly_data_item.rb +8 -0
- data/lib/cropio/resources/fuel_movement.rb +8 -0
- data/lib/cropio/resources/fuel_pump.rb +8 -0
- data/lib/cropio/resources/fuel_station.rb +8 -0
- data/lib/cropio/resources/fuel_tank.rb +8 -0
- data/lib/cropio/resources/fuel_type.rb +8 -0
- data/lib/cropio/resources/productivity_estimate.rb +8 -0
- data/lib/cropio/resources/productivity_estimate_peer.rb +8 -0
- data/lib/cropio/resources.rb +8 -1
- data/lib/cropio/version.rb +1 -1
- metadata +15 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a09b01ad2cd226e3d591674de9aaa57a007943ca2cbb1bc6358c65033bdad55d
|
4
|
+
data.tar.gz: ba52a445b1b305910025d0e6d7a83a3fa609beb6d78eecbbb6a918cfbe9729fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b596498baa740efbe0a7bc351969c420d7118d0e5a69e00a64c01b2a0868dc5159f5c3d9b74a07d1e33243452906417386de65d6a68e261d22b84b811870dec
|
7
|
+
data.tar.gz: 74b8d87d49bf12ea9e409d09cd6718f8525017f92202be56456e5ecc1f52e64d1ce5321b646a91cc1abe7eba72a8ba5188eae6c2427d3cac1669fc8718645f04
|
data/README.md
CHANGED
@@ -7,7 +7,9 @@ module Cropio
|
|
7
7
|
# Accepts reources name and params to perform HTTPS GET request.
|
8
8
|
def get(resource, query = {})
|
9
9
|
rmethod = extract_resource_method!(query)
|
10
|
-
|
10
|
+
id = extract_record_id!(query)
|
11
|
+
|
12
|
+
proxy(method: :get, url: url_for(resource, rmethod, id),
|
11
13
|
headers: { params: query })
|
12
14
|
end
|
13
15
|
|
@@ -28,17 +30,25 @@ module Cropio
|
|
28
30
|
|
29
31
|
protected
|
30
32
|
|
31
|
-
def url_for(resource, resource_method = nil)
|
33
|
+
def url_for(resource, resource_method = nil, id = nil)
|
32
34
|
url = "#{Cropio::Connection::Configurable::BASE_URL}/#{resource}"
|
33
35
|
url += "/#{resource_method}" if resource_method
|
36
|
+
url += "/#{id}" if id
|
34
37
|
url
|
35
38
|
end
|
36
39
|
|
37
40
|
def extract_resource_method!(query)
|
38
|
-
|
41
|
+
raise ArgumentError unless query.is_a?(Hash)
|
42
|
+
|
39
43
|
query.delete(:resource_method)
|
40
44
|
end
|
41
45
|
|
46
|
+
def extract_record_id!(query)
|
47
|
+
raise ArgumentError unless query.is_a?(Hash)
|
48
|
+
|
49
|
+
query.delete(:id)
|
50
|
+
end
|
51
|
+
|
42
52
|
def proxy(options)
|
43
53
|
options[:headers] ||= {}
|
44
54
|
options[:headers].merge!(headers)
|
@@ -48,10 +58,13 @@ module Cropio
|
|
48
58
|
rescue RestClient::UnprocessableEntity => e
|
49
59
|
puts JSON.parse(e.http_body)
|
50
60
|
raise e
|
61
|
+
rescue RestClient::NotFound
|
62
|
+
{}
|
51
63
|
end
|
52
64
|
|
53
65
|
def clear_params_in_options!(options)
|
54
66
|
return if options[:headers][:params].nil?
|
67
|
+
|
55
68
|
options[:headers][:params].reject! { |_k, v| v.nil? }
|
56
69
|
end
|
57
70
|
|
data/lib/cropio/resource/base.rb
CHANGED
@@ -42,6 +42,13 @@ module Cropio
|
|
42
42
|
to_instances(get_all_changes(from_time, to_time))
|
43
43
|
end
|
44
44
|
|
45
|
+
def self.find(id)
|
46
|
+
obj = PROXY.get(resources_name, id: id).fetch('data', nil)
|
47
|
+
return if obj.nil?
|
48
|
+
|
49
|
+
to_instance(obj)
|
50
|
+
end
|
51
|
+
|
45
52
|
# Returns persistance of the resource.
|
46
53
|
# Resource is persisted if it is saved
|
47
54
|
# and not deleted, if this resource exists
|
data/lib/cropio/resources.rb
CHANGED
@@ -62,7 +62,14 @@ require_relative './resources/land_document_land_parcel_mapping_item'
|
|
62
62
|
require_relative './resources/land_parcel'
|
63
63
|
require_relative './resources/protected_document'
|
64
64
|
require_relative './resources/productivity_estimate_history'
|
65
|
-
|
65
|
+
require_relative './resources/fuel_hourly_data_item'
|
66
|
+
require_relative './resources/productivity_estimate'
|
67
|
+
require_relative './resources/productivity_estimate_peer'
|
68
|
+
require_relative './resources/fuel_station'
|
69
|
+
require_relative './resources/fuel_type'
|
70
|
+
require_relative './resources/fuel_tank'
|
71
|
+
require_relative './resources/fuel_pump'
|
72
|
+
require_relative './resources/fuel_movement'
|
66
73
|
|
67
74
|
module Cropio
|
68
75
|
module Resources
|
data/lib/cropio/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cropio-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.31'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergey Vernidub
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -96,7 +96,7 @@ dependencies:
|
|
96
96
|
version: '0'
|
97
97
|
description: 'Cropio-Ruby provides simple ActiveRecord-like wrappings for Cropio API
|
98
98
|
|
99
|
-
'
|
99
|
+
'
|
100
100
|
email:
|
101
101
|
- info@cropio.com
|
102
102
|
executables: []
|
@@ -145,6 +145,12 @@ files:
|
|
145
145
|
- lib/cropio/resources/field_scout_report_threat_mapping_item.rb
|
146
146
|
- lib/cropio/resources/field_shape.rb
|
147
147
|
- lib/cropio/resources/field_shape_land_parcel_mapping_item.rb
|
148
|
+
- lib/cropio/resources/fuel_hourly_data_item.rb
|
149
|
+
- lib/cropio/resources/fuel_movement.rb
|
150
|
+
- lib/cropio/resources/fuel_pump.rb
|
151
|
+
- lib/cropio/resources/fuel_station.rb
|
152
|
+
- lib/cropio/resources/fuel_tank.rb
|
153
|
+
- lib/cropio/resources/fuel_type.rb
|
148
154
|
- lib/cropio/resources/group_folder.rb
|
149
155
|
- lib/cropio/resources/harvest_weighing.rb
|
150
156
|
- lib/cropio/resources/historical_value.rb
|
@@ -173,7 +179,9 @@ files:
|
|
173
179
|
- lib/cropio/resources/note.rb
|
174
180
|
- lib/cropio/resources/photo.rb
|
175
181
|
- lib/cropio/resources/plant_threat.rb
|
182
|
+
- lib/cropio/resources/productivity_estimate.rb
|
176
183
|
- lib/cropio/resources/productivity_estimate_history.rb
|
184
|
+
- lib/cropio/resources/productivity_estimate_peer.rb
|
177
185
|
- lib/cropio/resources/protected_document.rb
|
178
186
|
- lib/cropio/resources/satellite_image.rb
|
179
187
|
- lib/cropio/resources/seed.rb
|
@@ -195,7 +203,7 @@ homepage: https://github.com/cropio/cropio-ruby
|
|
195
203
|
licenses:
|
196
204
|
- MIT
|
197
205
|
metadata: {}
|
198
|
-
post_install_message:
|
206
|
+
post_install_message:
|
199
207
|
rdoc_options: []
|
200
208
|
require_paths:
|
201
209
|
- lib
|
@@ -210,8 +218,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
218
|
- !ruby/object:Gem::Version
|
211
219
|
version: '0'
|
212
220
|
requirements: []
|
213
|
-
rubygems_version: 3.
|
214
|
-
signing_key:
|
221
|
+
rubygems_version: 3.2.15
|
222
|
+
signing_key:
|
215
223
|
specification_version: 4
|
216
224
|
summary: Cropio API bindings for Ruby
|
217
225
|
test_files: []
|