cropio-ruby 0.20 → 0.32

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a20b1892eee7c583544a099873c23b21d0a3d292f3cc85e22c0c6e4bccbd7e63
4
- data.tar.gz: adf3177b00cfe063aae9552d846c6ceb1e18bda4da319cc7a10fcd5859106fd1
3
+ metadata.gz: 832c9a3eb8e7b266f7466e3c9a5ddf96ad58a833a89e3049ea1b5dfb2cdc0b41
4
+ data.tar.gz: '058fec100bde5c710cf07c82d8a84a8233a1517eae946b9bfee026a278d18cc1'
5
5
  SHA512:
6
- metadata.gz: 82c1ead15e22f999cbaf74d36df2f37c7d333d327cab188113c32a2d7245cb574441f4d9e0553de3344dc4630278f2b2932607048d678aeae057a03aec8f05b8
7
- data.tar.gz: fb992dc5971306f34ab89df2f1eee169828a74763ffb76bd3722567ff5d040095a67916585e7593a3a9a6d0476d2b6840f32197cfc5447898055c4771e185f48
6
+ metadata.gz: 283317dbeff4918a132d062826cb591056e462f60cc45c9b37bbf660010722d6fa1af7450a307ca86d6c8a010581ebba5a08d385af5dd51587d7805027a190c9
7
+ data.tar.gz: 500e8bfe2a67dc843e17d271bce9b261ae5e68cd3256c7251281e025f2596eab85bab50906a3bb8cebc0961a61a1b624781e14be7456d0877a9ea90b6b497658
data/README.md CHANGED
@@ -56,6 +56,11 @@ Currently supported API methods is:
56
56
  Crop.all
57
57
  ```
58
58
 
59
+ - get record by id
60
+ ```ruby
61
+ Crop.find(1)
62
+ ```
63
+
59
64
  - create
60
65
 
61
66
  ```ruby
@@ -3,8 +3,8 @@ module Cropio
3
3
  # Contains logic for requests configuration
4
4
  # like appending headers to requests.
5
5
  module Configurable
6
- # Cropio's server and API's entry point url
7
- BASE_URL = 'https://cropio.com/api/v3'
6
+ # Cropwise server and API's entry point url
7
+ BASE_URL = 'https://operations.cropwise.com/api/v3'
8
8
 
9
9
  protected
10
10
 
@@ -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
- proxy(method: :get, url: url_for(resource, rmethod),
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
- fail(ArgumentError) unless query.is_a?(Hash)
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
 
@@ -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
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cropio
4
+ module Resources
5
+ class FuelMovement < Cropio::Resource::Base
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cropio
4
+ module Resources
5
+ class FuelPump < Cropio::Resource::Base
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cropio
4
+ module Resources
5
+ class FuelStation < Cropio::Resource::Base
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cropio
4
+ module Resources
5
+ class FuelTank < Cropio::Resource::Base
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cropio
4
+ module Resources
5
+ class FuelType < Cropio::Resource::Base
6
+ end
7
+ end
8
+ end
@@ -65,6 +65,11 @@ require_relative './resources/productivity_estimate_history'
65
65
  require_relative './resources/fuel_hourly_data_item'
66
66
  require_relative './resources/productivity_estimate'
67
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'
68
73
 
69
74
  module Cropio
70
75
  module Resources
@@ -1,3 +1,3 @@
1
1
  module Cropio
2
- VERSION = '0.20'.freeze
2
+ VERSION = '0.32'.freeze
3
3
  end
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.20'
4
+ version: '0.32'
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: 2020-09-16 00:00:00.000000000 Z
11
+ date: 2022-03-10 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: []
@@ -113,8 +113,6 @@ files:
113
113
  - bin/console
114
114
  - bin/login
115
115
  - bin/setup
116
- - cropio-ruby-0.18.gem
117
- - cropio-ruby-0.19.gem
118
116
  - cropio-ruby.gemspec
119
117
  - lib/cropio.rb
120
118
  - lib/cropio/connection.rb
@@ -148,6 +146,11 @@ files:
148
146
  - lib/cropio/resources/field_shape.rb
149
147
  - lib/cropio/resources/field_shape_land_parcel_mapping_item.rb
150
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
151
154
  - lib/cropio/resources/group_folder.rb
152
155
  - lib/cropio/resources/harvest_weighing.rb
153
156
  - lib/cropio/resources/historical_value.rb
@@ -200,7 +203,7 @@ homepage: https://github.com/cropio/cropio-ruby
200
203
  licenses:
201
204
  - MIT
202
205
  metadata: {}
203
- post_install_message:
206
+ post_install_message:
204
207
  rdoc_options: []
205
208
  require_paths:
206
209
  - lib
@@ -215,8 +218,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
215
218
  - !ruby/object:Gem::Version
216
219
  version: '0'
217
220
  requirements: []
218
- rubygems_version: 3.0.3
219
- signing_key:
221
+ rubygems_version: 3.2.15
222
+ signing_key:
220
223
  specification_version: 4
221
224
  summary: Cropio API bindings for Ruby
222
225
  test_files: []
data/cropio-ruby-0.18.gem DELETED
Binary file
data/cropio-ruby-0.19.gem DELETED
Binary file