{"id":27160498,"url":"https://github.com/beaorn/agx-ruby","last_synced_at":"2025-04-09T00:01:31.929Z","repository":{"id":62553075,"uuid":"67555762","full_name":"brycejohnston/agx-ruby","owner":"brycejohnston","description":"Ruby client for Proagrica's agX Platform APIs","archived":false,"fork":false,"pushed_at":"2023-08-03T18:59:24.000Z","size":43,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-31T06:02:14.627Z","etag":null,"topics":["agriculture"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/agx","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brycejohnston.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-09-06T23:59:53.000Z","updated_at":"2023-09-11T04:47:06.000Z","dependencies_parsed_at":"2022-11-03T04:15:26.910Z","dependency_job_id":null,"html_url":"https://github.com/brycejohnston/agx-ruby","commit_stats":{"total_commits":53,"total_committers":2,"mean_commits":26.5,"dds":"0.037735849056603765","last_synced_commit":"28d4989988071e186450d1827c46b04d4a666ad3"},"previous_names":["cropquest/agx-ruby","beaorn/agx-ruby"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brycejohnston%2Fagx-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brycejohnston%2Fagx-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brycejohnston%2Fagx-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brycejohnston%2Fagx-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brycejohnston","download_url":"https://codeload.github.com/brycejohnston/agx-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247947842,"owners_count":21023065,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agriculture"],"created_at":"2025-04-09T00:01:03.500Z","updated_at":"2025-04-09T00:01:31.899Z","avatar_url":"https://github.com/brycejohnston.png","language":"Ruby","funding_links":[],"categories":["Data Standardization, Interoperability and APIs"],"sub_categories":[],"readme":"# agX Platform API Client\n\n[![Gem Version](http://img.shields.io/gem/v/agx.svg)][gem]\n\n[gem]: https://rubygems.org/gems/agx\n\nRuby client for accessing Proagrica's [agX Platform APIs](https://proagrica.com/products/agx/).\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'agx'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install agx\n\n## Usage\n\n### agX Content API\n\nSetup agX Content Client (OAuth 2 Client Credentials Flow)\n```ruby\n@agx_content_client = Agx::Content::Client.new(\n  client_id: \"your_client_id\",\n  client_secret: \"your_client_secret\",\n  version: \"v1\"  # optional\n  prod: true # optional, false for QA\n  access_token: \"token_if_stored\", # optional\n  expires_at: \"token_expires_at_if_stored\" # optional\n)\n```\n\nMake get requests for Content API resources\n```ruby\n# @agx_content_client.get(\"ResourceName\", params_hash)\n# =\u003e 'parsed_json_response_body'\n\ncrops = @agx_content_client.get(\"Crop\")\n\n# Passing in publishDate as param\nweeds = @agx_content_client.get(\"Weed\", {publishDate: date.to_s})\n```\n\n### agX Sync API\n\nSetup agX Sync Client (OAuth 2.0 / OpenID Connect 1.0 Authorization Code Flow)\n\n***This requires that you have already previously authenticated and authorized\na user to agX with required scopes through the authorization code grant flow process\nand have persisted their sync ID, access token, refresh token, and access token\nexpiration timestamp.***\n\n```ruby\n@agx_sync_client = Agx::Sync::Client.new(\n  client_id: \"your_client_id\",\n  client_secret: \"your_client_secret\",\n  version: \"v4\",  # optional\n  sync_id: \"agx_user_sync_id\",\n  access_token: \"agx_user_agx_token\",\n  refresh_token: \"agx_user_refresh_token\",\n  token_expires_at: \"access_token_expiration_timestamp\",\n  transaction_id: \"agx_user_previous_transaction_id\", # optional\n  prod: true # optional, false for QA\n)\n```\n\nInitiate a sync transaction, make Sync API requests, and end transaction\n\n```ruby\n# To make calls without starting a transaction for resources that don't\n# require it, use the get_nt method (GET only requests don't need transactions)\n# @agx_sync_client.get_nt(\"Resource\", start_time)\n# =\u003e 'parsed_json_response_body'\ngrowers = @agx_sync_client.get_nt(\"Grower\")\n\n# To make calls that require transactions (sync locking), call start_transaction\n# and then use the get method to call for the resource. You should persist\n# transaction ID per user until transaction is successfully ended by call\n# to end_transaction\ntransaction_id = @agx_sync_client.start_transaction\n\n# @agx_sync_client.get(\"Resource\", start_time)\n# =\u003e 'parsed_json_response_body'\ngrowers = @agx_sync_client.get(\"Grower\")\n\n# Get all farms accessible for a grower\nfarms = @agx_sync_client.get(\"Grower/#{grower.guid}/Farm\")\n\n# Get all server changes on farms accessible for a grower since start_time\nfarms = @agx_sync_client.get(\"Grower/#{grower.guid}/Farm\", last_sync_date.to_s)\n\n# Put (insert) a new Grower\nnow = Time.now.utc\nnew_grower = {\n  \"SyncID\": @agx_sync_client.sync_id,\n  \"ID\": SecureRandom.uuid,\n  \"Name\": \"MYNEWGROWER\",\n  \"ModifiedOn\": now,\n  \"CreatedOn\": now,\n  \"CreatorID\": @agx_sync_client.sync_id,\n  \"EditorID\": @agx_sync_client.sync_id,\n  \"SchemaVersion\": \"4.0\"\n}\n\n@client.put(\"Grower\", new_grower.to_json)\n\n# etc...\n\n@agx_sync_client.end_transaction\n\n# clear the persisted transaction ID for user after ending sync transaction\nuser_transaction_id = nil\n```\n\n## Development\n\nAfter 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`.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/beaorn/agx-ruby.\n\n\n## License\n\nThe gem is available as open source under the terms of the MIT License (see [LICENSE.txt](https://github.com/beaorn/agx-ruby/blob/master/LICENSE.txt))\n\n[agX](https://proagrica.com/products/agx/) is a registered trademark of [Proagrica](https://proagrica.com).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeaorn%2Fagx-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeaorn%2Fagx-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeaorn%2Fagx-ruby/lists"}