This repository hosts the DigitalHumani Ruby Gem SDK. It can be used for interacting with the DigitalHumani RaaS (Reforestation-as-a-Service) API.
Add this line to your application's Gemfile:
gem'digitalhumani'And then execute:
$ bundle install
Or install it yourself as:
$ gem install digitalhumani
- Create an account on DigitalHumani,com and grab your API key from the Developer menu item.
- Note that you'll use a different API key per environment (production vs sandbox)
- Review the DigitalHumani documentation to familiarize yourself with the environments, requests, projects, etc
# Initialize the DigitalHumani SDK instancedh=DigitalHumani::SDK.newdo@api_key= $API_KEY # your API key@environment="production"# "production" or "sandbox"@enterprise_id= $ENTERPRISE_ID # optional; your enterprise IDendAlternatively, you can specify and update the enterprise_id separately:
digitalHumani.enterprise_id= $ENTERPRISE_IDNote that when enterprise_id has been specified on the instance, it will be used as a default value on all below methods and therefore does not need to be provided as a parameter.
# Plant one or many treesdigitalHumani.plant_tree(enterprise_id: $ENTERPRISE_ID,project_id: '81818181',user: 'test@example.com',treeCount: 5)# Get details of a single tree-planting requestdigitalHumani.tree(uuid: $TREE_UUID)# Get enterprise by IDdigitalHumani.enterprise(enterprise_id: $ENTERPRISE_ID)# Get count of trees planted by date rangedigitalHumani.treeCount(enterprise_id: $ENTERPRISE_ID,start: '2021-01-01',end: '2022-01-01')# Get count of trees planted for monthdigitalHumani.treeCount(enterprise_id: $ENTERPRISE_ID,month: '2021-01')# Get count of trees planted by specific user. User string will match what's specified in `plant_tree` calldigitalHumani.treeCount(enterprise_id: $ENTERPRISE_ID,user: 'test@example.com')# Get list of all projectsdigitalHumani.projects()# Get project by IDdigitalHumani.project(project_id: '81818181')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. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/digitalhumani/digitalhumani-ruby-sdk.
The gem is available as open source under the terms of the MIT License.