agx 0.2.5 → 0.3.0

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: c786b01d2fd0875eaa51abaa9f21a3669ee747a754834fb4a01984706a3a18a9
4
- data.tar.gz: 9f6577a8276c34d4351a43dfdc4aba958724f8ac5ac19578adcbde76495fa63f
3
+ metadata.gz: e857bc1af586908c17bd9d4979f4d6da3b973e27cec3fa30f5708e76babdf8ad
4
+ data.tar.gz: a0f1d070afad995898c7793d5fdcc5a52a58bcb4e6c0bef106e0a67d43fb1ed5
5
5
  SHA512:
6
- metadata.gz: 9d28ce15cfc652a053b107bfa83545d000c009621dff0b7028d381e0d3097972a15ab40da6c81ed7183071cc825773eba19bbb9a46dfe6d66fcdd5841821fc9f
7
- data.tar.gz: 1d189d91067e1ce73c38b5f780b6fb3461db778158c5036d8b36c08cdbc676e9b34c286207b545cd0bdc287c666408b42885a295a6663fc2cfae69de341c7d4f
6
+ metadata.gz: e67bdc8cb9b810593cc3fd57b4332104fa005c8821250549b723d08eef6af666b444441ea3e08a9053841c68012b499b5eacf4d09d2f1ef6db13056a0cdf2586
7
+ data.tar.gz: 3ed758095b42bd65d51230ece29d2224380af76f1f0384fb2f4a9fa9341eded7d70a2a9d1b1b35db3a3e36d7f97b3dc17e19e539be311e6d9945d8d60d7c7ac4
data/Gemfile CHANGED
@@ -1,4 +1,9 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ git_source(:github) do |repo_name|
4
+ repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
5
+ "https://github.com/#{repo_name}.git"
6
+ end
7
+
3
8
  # Specify your gem's dependencies in agx.gemspec
4
9
  gemspec
@@ -1,4 +1,4 @@
1
- Copyright (c) 2018 Bryce Johnston
1
+ Copyright (c) 2020 Bryce Johnston
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
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/beaorn/agx-ruby.
127
+ Bug reports and pull requests are welcome on GitHub at https://github.com/cropquest/agx-ruby.
147
128
 
148
129
 
149
130
  ## License
@@ -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@beaorn.com"]
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/beaorn/agx-ruby"
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.12"
26
- spec.add_development_dependency "rake", "~> 10.0"
27
- spec.add_development_dependency "rspec", "~> 3.0"
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
@@ -117,7 +117,10 @@ module Agx
117
117
  @client_id,
118
118
  @client_secret,
119
119
  site: @site,
120
- token_url: @token_url
120
+ token_url: @token_url,
121
+ connection_opts: {
122
+ request: { timeout: 90 }
123
+ }
121
124
  )
122
125
  end
123
126
 
@@ -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.body == "The specified transaction is invalid or expired."
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
  )
@@ -1,3 +1,3 @@
1
1
  module Agx
2
- VERSION = "0.2.5"
2
+ VERSION = "0.3.0"
3
3
  end
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.5
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: 2018-07-22 00:00:00.000000000 Z
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.12'
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.12'
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: '10.0'
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: '10.0'
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.0'
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.0'
82
+ version: '3.9'
83
83
  description: Ruby client for accessing Proagrica's agX Platform APIs.
84
84
  email:
85
- - bryce@beaorn.com
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/beaorn/agx-ruby
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
- rubyforge_project:
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.