0.0
Low commit activity in last 3 years
No release in over a year
The official Ruby SDK for DigitalHumani's RaaS (Reforestation-as-a-Service)
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.0
~> 3.14

Runtime

~> 1.7.0
 Project Readme

DigitalHumani Ruby SDK

This repository hosts the DigitalHumani Ruby Gem SDK. It can be used for interacting with the DigitalHumani RaaS (Reforestation-as-a-Service) API.

Installation

Add this line to your application's Gemfile:

gem 'digitalhumani'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install digitalhumani

Preparation

  • 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

Usage

Configuration

# Initialize the DigitalHumani SDK instance
dh = DigitalHumani::SDK.new do
    @api_key = $API_KEY             # your API key
    @environment = "production"     # "production" or "sandbox"
    @enterprise_id = $ENTERPRISE_ID # optional; your enterprise ID
end

Alternatively, you can specify and update the enterprise_id separately:

digitalHumani.enterprise_id = $ENTERPRISE_ID

Note 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.

Trees

# Plant one or many trees
digitalHumani.plant_tree(enterprise_id: $ENTERPRISE_ID, project_id: '81818181', user: 'test@example.com', treeCount: 5)

# Get details of a single tree-planting request
digitalHumani.tree(uuid: $TREE_UUID)

Enterprises

# Get enterprise by ID
digitalHumani.enterprise(enterprise_id: $ENTERPRISE_ID)

# Get count of trees planted by date range
digitalHumani.treeCount(enterprise_id: $ENTERPRISE_ID, start: '2021-01-01', end: '2022-01-01')

# Get count of trees planted for month
digitalHumani.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` call
digitalHumani.treeCount(enterprise_id: $ENTERPRISE_ID, user: 'test@example.com')

Projects

# Get list of all projects
digitalHumani.projects()

# Get project by ID
digitalHumani.project(project_id: '81818181')

Development

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.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/digitalhumani/digitalhumani-ruby-sdk.

License

The gem is available as open source under the terms of the MIT License.