agx 0.2.5 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -0
- data/LICENSE.txt +1 -1
- data/README.md +16 -35
- data/agx.gemspec +6 -6
- data/lib/agx/content/client.rb +4 -1
- data/lib/agx/sync/client.rb +17 -1
- data/lib/agx/version.rb +1 -1
- metadata +11 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e857bc1af586908c17bd9d4979f4d6da3b973e27cec3fa30f5708e76babdf8ad
|
4
|
+
data.tar.gz: a0f1d070afad995898c7793d5fdcc5a52a58bcb4e6c0bef106e0a67d43fb1ed5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e67bdc8cb9b810593cc3fd57b4332104fa005c8821250549b723d08eef6af666b444441ea3e08a9053841c68012b499b5eacf4d09d2f1ef6db13056a0cdf2586
|
7
|
+
data.tar.gz: 3ed758095b42bd65d51230ece29d2224380af76f1f0384fb2f4a9fa9341eded7d70a2a9d1b1b35db3a3e36d7f97b3dc17e19e539be311e6d9945d8d60d7c7ac4
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -72,7 +72,6 @@ expiration timestamp.***
|
|
72
72
|
|
73
73
|
Initiate a sync transaction, make Sync API requests, and end transaction
|
74
74
|
|
75
|
-
***Currently only get requests are supported***
|
76
75
|
```ruby
|
77
76
|
# To make calls without starting a transaction for resources that don't
|
78
77
|
# require it, use the get_nt method
|
@@ -96,6 +95,21 @@ farms = @agx_sync_client.get("Grower/#{grower.guid}/Farm")
|
|
96
95
|
# Get all server changes on farms accessible for a grower since start_time
|
97
96
|
farms = @agx_sync_client.get("Grower/#{grower.guid}/Farm", last_sync_date.to_s)
|
98
97
|
|
98
|
+
# Put (insert) a new Grower
|
99
|
+
now = Time.now.utc
|
100
|
+
new_grower = {
|
101
|
+
"SyncID": @agx_sync_client.sync_id,
|
102
|
+
"ID": SecureRandom.uuid,
|
103
|
+
"Name": "MYNEWGROWER",
|
104
|
+
"ModifiedOn": now,
|
105
|
+
"CreatedOn": now,
|
106
|
+
"CreatorID": @agx_sync_client.sync_id,
|
107
|
+
"EditorID": @agx_sync_client.sync_id,
|
108
|
+
"SchemaVersion": "4.0"
|
109
|
+
}
|
110
|
+
|
111
|
+
@client.put("Grower", new_grower.to_json)
|
112
|
+
|
99
113
|
# etc...
|
100
114
|
|
101
115
|
@agx_sync_client.end_transaction
|
@@ -104,46 +118,13 @@ farms = @agx_sync_client.get("Grower/#{grower.guid}/Farm", last_sync_date.to_s)
|
|
104
118
|
user_transaction_id = nil
|
105
119
|
```
|
106
120
|
|
107
|
-
### agX Pictures API
|
108
|
-
|
109
|
-
*Note: The pictures API client implementation still needs more work.*
|
110
|
-
|
111
|
-
Setup agX Pictures Client
|
112
|
-
|
113
|
-
```ruby
|
114
|
-
@agx_pictures_client = Agx::Pictures::Client.new(
|
115
|
-
client_id: "your_client_id",
|
116
|
-
client_secret: "your_client_secret",
|
117
|
-
version: "v1", # optional
|
118
|
-
sync_id: "agx_user_sync_id",
|
119
|
-
access_token: "agx_user_agx_token",
|
120
|
-
refresh_token: "agx_user_refresh_token",
|
121
|
-
token_expires_at: "access_token_expiration_timestamp",
|
122
|
-
filepath: "/path/to/pictures/",
|
123
|
-
prod: true # optional, false for QA
|
124
|
-
)
|
125
|
-
```
|
126
|
-
|
127
|
-
Make get requests for Pictures API images and metadata
|
128
|
-
|
129
|
-
***Currently only get requests are supported***
|
130
|
-
```ruby
|
131
|
-
|
132
|
-
# Get metadata
|
133
|
-
image_meta = @agx_pictures_client.get_metadata("661ee0c0-0cbc-4a7b-be39-1a9de49acc86")
|
134
|
-
|
135
|
-
# Get image and save to {filepath}/{sync_id}_{picture_id}.jpeg
|
136
|
-
image = @agx_pictures_client.get("661ee0c0-0cbc-4a7b-be39-1a9de49acc86")
|
137
|
-
# => "/path/to/pictures/7_661ee0c0-0cbc-4a7b-be39-1a9de49acc86.jpeg"
|
138
|
-
```
|
139
|
-
|
140
121
|
## Development
|
141
122
|
|
142
123
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run `bundle exec rake install`.
|
143
124
|
|
144
125
|
## Contributing
|
145
126
|
|
146
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
127
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/cropquest/agx-ruby.
|
147
128
|
|
148
129
|
|
149
130
|
## License
|
data/agx.gemspec
CHANGED
@@ -7,11 +7,11 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "agx"
|
8
8
|
spec.version = Agx::VERSION
|
9
9
|
spec.authors = ["Bryce Johnston"]
|
10
|
-
spec.email = ["bryce@
|
10
|
+
spec.email = ["bryce.johnston@hey.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{Ruby client for accessing agX Platform APIs.}
|
13
13
|
spec.description = %q{Ruby client for accessing Proagrica's agX Platform APIs.}
|
14
|
-
spec.homepage = "https://github.com/
|
14
|
+
spec.homepage = "https://github.com/cropquest/agx-ruby"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_dependency "oj", "< 4"
|
23
23
|
spec.add_dependency "oauth2", "< 2"
|
24
24
|
|
25
|
-
spec.add_development_dependency "bundler", "~> 1
|
26
|
-
spec.add_development_dependency "rake", "~>
|
27
|
-
spec.add_development_dependency "rspec", "~> 3.
|
28
|
-
end
|
25
|
+
spec.add_development_dependency "bundler", "~> 2.1"
|
26
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.9"
|
28
|
+
end
|
data/lib/agx/content/client.rb
CHANGED
data/lib/agx/sync/client.rb
CHANGED
@@ -66,6 +66,19 @@ module Agx
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
def put(resource, body)
|
70
|
+
validate_sync_attributes
|
71
|
+
|
72
|
+
url = "#{@api_url}#{resource}?transactionId=#{@transaction_id}"
|
73
|
+
|
74
|
+
begin
|
75
|
+
response = current_token.put(url, {:body => body, :headers => @headers})
|
76
|
+
parse_response(response.body)
|
77
|
+
rescue => e
|
78
|
+
handle_error(e)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
69
82
|
def start_transaction
|
70
83
|
validate_credentials
|
71
84
|
|
@@ -95,7 +108,7 @@ module Agx
|
|
95
108
|
)
|
96
109
|
return true
|
97
110
|
rescue => e
|
98
|
-
if e.response && e.response.
|
111
|
+
if e.response && e.response.status && e.response.status.to_i >= 400
|
99
112
|
return true
|
100
113
|
else
|
101
114
|
handle_error(e)
|
@@ -190,6 +203,9 @@ module Agx
|
|
190
203
|
token_url: @token_url,
|
191
204
|
options: {
|
192
205
|
ssl: { ca_path: "/usr/lib/ssl/certs" }
|
206
|
+
},
|
207
|
+
connection_opts: {
|
208
|
+
request: { timeout: 90 }
|
193
209
|
}
|
194
210
|
}
|
195
211
|
)
|
data/lib/agx/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryce Johnston
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -44,45 +44,45 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1
|
47
|
+
version: '2.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1
|
54
|
+
version: '2.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '13.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '13.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
75
|
+
version: '3.9'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
82
|
+
version: '3.9'
|
83
83
|
description: Ruby client for accessing Proagrica's agX Platform APIs.
|
84
84
|
email:
|
85
|
-
- bryce@
|
85
|
+
- bryce.johnston@hey.com
|
86
86
|
executables: []
|
87
87
|
extensions: []
|
88
88
|
extra_rdoc_files: []
|
@@ -106,7 +106,7 @@ files:
|
|
106
106
|
- lib/agx/sync.rb
|
107
107
|
- lib/agx/sync/client.rb
|
108
108
|
- lib/agx/version.rb
|
109
|
-
homepage: https://github.com/
|
109
|
+
homepage: https://github.com/cropquest/agx-ruby
|
110
110
|
licenses:
|
111
111
|
- MIT
|
112
112
|
metadata: {}
|
@@ -125,8 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
- !ruby/object:Gem::Version
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
|
-
|
129
|
-
rubygems_version: 2.7.6
|
128
|
+
rubygems_version: 3.1.2
|
130
129
|
signing_key:
|
131
130
|
specification_version: 4
|
132
131
|
summary: Ruby client for accessing agX Platform APIs.
|