agx 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE.txt +1 -1
- data/README.md +12 -5
- data/agx.gemspec +1 -1
- data/lib/agx/sync/client.rb +25 -0
- data/lib/agx/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d101f036ad3ca77c3210c91b0f15d8a38e9e8acaec7d2cf20f4b51089904a89e
|
4
|
+
data.tar.gz: b62ff40f0118fe22d5eb0cf3f1e73435cd280cf8008cdc47922ce5e1f7664bde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a5a30e877163b35a2175d904816ea184f7fea9e1f2ec32d031f5a73e34a4aa7ca4c2ee513fe90086894a1e734dd12c019c45575bfe1e4131e1248f3c2d10b21
|
7
|
+
data.tar.gz: 7d9d43c10d4bedfbd34830c9bb801eecffebfdac0514f82032b11d61e8817b55f314b0662fe2ffed8b5d73ac2609fdf2e3e524e700d6bc66aa2d2dbcec8876e7
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -74,13 +74,20 @@ Initiate a sync transaction, make Sync API requests, and end transaction
|
|
74
74
|
|
75
75
|
***Currently only get requests are supported***
|
76
76
|
```ruby
|
77
|
-
#
|
77
|
+
# To make calls without starting a transaction for resources that don't
|
78
|
+
# require it, use the get_nt method
|
79
|
+
# @agx_sync_client.get_nt("Resource", start_time)
|
78
80
|
# => 'parsed_json_response_body'
|
81
|
+
growers = @agx_sync_client.get_nt("Grower")
|
79
82
|
|
80
|
-
#
|
81
|
-
#
|
83
|
+
# To make calls that require transactions (sync locking), call start_transaction
|
84
|
+
# and then use the get method to call for the resource. You should persist
|
85
|
+
# transaction ID per user until transaction is successfully ended by call
|
86
|
+
# to end_transaction
|
82
87
|
transaction_id = @agx_sync_client.start_transaction
|
83
88
|
|
89
|
+
# @agx_sync_client.get("Resource", start_time)
|
90
|
+
# => 'parsed_json_response_body'
|
84
91
|
growers = @agx_sync_client.get("Grower")
|
85
92
|
|
86
93
|
# Get all farms accessible for a grower
|
@@ -134,11 +141,11 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
134
141
|
|
135
142
|
## Contributing
|
136
143
|
|
137
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
144
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/AgDevelopers/agx-ruby.
|
138
145
|
|
139
146
|
|
140
147
|
## License
|
141
148
|
|
142
|
-
The gem is available as open source under the terms of the MIT License (see [LICENSE.txt](https://github.com/
|
149
|
+
The gem is available as open source under the terms of the MIT License (see [LICENSE.txt](https://github.com/AgDevelopers/agx-ruby/blob/master/LICENSE.txt))
|
143
150
|
|
144
151
|
[agX](http://www.agxplatform.com/) is a registered trademark of [SST Software](http://www.sstsoftware.com/).
|
data/agx.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = %q{Ruby client for accessing agX Platform APIs.}
|
13
13
|
spec.description = %q{Ruby client for accessing SST Software's agX Platform APIs.}
|
14
|
-
spec.homepage = "https://github.com/
|
14
|
+
spec.homepage = "https://github.com/AgDevelopers/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)/}) }
|
data/lib/agx/sync/client.rb
CHANGED
@@ -50,6 +50,22 @@ module Agx
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
def get_nt(resource, start_time = nil)
|
54
|
+
validate_nt_sync_attributes
|
55
|
+
|
56
|
+
url = "#{@api_url}#{resource}"
|
57
|
+
if !start_time.nil?
|
58
|
+
url = "#{@api_url}#{resource}?startTime=#{start_time}"
|
59
|
+
end
|
60
|
+
|
61
|
+
begin
|
62
|
+
response = current_token.get(url, :headers => @headers)
|
63
|
+
parse_response(response.body)
|
64
|
+
rescue => e
|
65
|
+
handle_error(e)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
53
69
|
def start_transaction
|
54
70
|
validate_credentials
|
55
71
|
|
@@ -105,6 +121,15 @@ module Agx
|
|
105
121
|
end
|
106
122
|
end
|
107
123
|
|
124
|
+
def validate_nt_sync_attributes
|
125
|
+
validate_credentials
|
126
|
+
|
127
|
+
unless @sync_id
|
128
|
+
error = Agx::Error.new("agX Sync Transaction Attributes Not Set", {title: "AGX_SYNC_ATTRIBUTES_ERROR"})
|
129
|
+
raise error
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
108
133
|
def parse_response(response_body)
|
109
134
|
parsed_response = nil
|
110
135
|
|
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.2.
|
4
|
+
version: 0.2.3
|
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: 2018-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -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/AgDevelopers/agx-ruby
|
110
110
|
licenses:
|
111
111
|
- MIT
|
112
112
|
metadata: {}
|
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
126
|
version: '0'
|
127
127
|
requirements: []
|
128
128
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
129
|
+
rubygems_version: 2.7.3
|
130
130
|
signing_key:
|
131
131
|
specification_version: 4
|
132
132
|
summary: Ruby client for accessing agX Platform APIs.
|