All Projects → patch-technology → patch-ruby

patch-technology / patch-ruby

Licence: other
Patch's Ruby client library - https://www.patch.io

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to patch-ruby

pi-eco-indicator
Display at-a-glance data of carbon intensity or Octopus Agile prices on a Pimoroni Blinkt! display or a Pimoroni Inky pHAT display.
Stars: ✭ 15 (-70%)
Mutual labels:  climate, carbon, carbon-emissions, climate-change
hockeystick
Download and Visualize Essential Global Heating Data in R
Stars: ✭ 42 (-16%)
Mutual labels:  climate, carbon, carbon-emissions, climate-change
openair-cyan
DIY small-scale open hardware direct air carbon capture device called Cyan. Our documentation is on https://openair-collective.github.io/openair-cyan
Stars: ✭ 54 (+8%)
Mutual labels:  climate, carbon, climate-change
Climate-Change-Datasets
Here is a list of Climate Change Public Datasets 🌦🌪🌫🌀💧🌊
Stars: ✭ 115 (+130%)
Mutual labels:  climate, climate-change
blockchain-carbon-accounting
This project implements blockchain applications for climate action and accounting, including emissions calculations, carbon trading, and validation of climate claims. It is part of the Linux Foundation's Hyperledger Climate Action and Accounting SIG.
Stars: ✭ 123 (+146%)
Mutual labels:  climate, climate-change
openclimate-demo
Open Climate Repo
Stars: ✭ 54 (+8%)
Mutual labels:  climate, climate-change
cloud-carbon-footprint
Cloud Carbon Footprint is a tool to estimate energy use (kilowatt-hours) and carbon emissions (metric tons CO2e) from public cloud usage
Stars: ✭ 510 (+920%)
Mutual labels:  climate, carbon-emissions
climateconnect
The global climate action web platform. 🌏
Stars: ✭ 45 (-10%)
Mutual labels:  climate, climate-change
awesome-forests
🌳 A curated list of ground-truth forest datasets for the machine learning and forestry community.
Stars: ✭ 111 (+122%)
Mutual labels:  carbon, climate-change
hector
The Hector Simple Climate Model
Stars: ✭ 72 (+44%)
Mutual labels:  climate, climate-change
hacktoberfest-2020
Let's tackle the Climate-Change together with Open-Source 🌍 + 👩‍💻
Stars: ✭ 23 (-54%)
Mutual labels:  climate, climate-change
netpositive-money.github.io
Bitcoiners contributing to climate change solutions - the website
Stars: ✭ 17 (-66%)
Mutual labels:  climate, climate-change
trends.earth
trends.earth - measure land change
Stars: ✭ 69 (+38%)
Mutual labels:  climate, climate-change
ClimateChangeProjections
An embeddable map that shows climate change projections. How hot will it be by 2070 if we don't do something about it? Accessible at https://climatechange.codeforafrica.org
Stars: ✭ 29 (-42%)
Mutual labels:  climate, climate-change
whoisresponsible.us
🌏 Climate change vulnerability, preparedness, and contribution data in a choropleth map and bar graph.
Stars: ✭ 18 (-64%)
Mutual labels:  climate-change
CUMULO
a benchmark dataset for training and evaluating global cloud classification models.
Stars: ✭ 20 (-60%)
Mutual labels:  climate-change
wumpfetch
🚀🔗 A modern, lightweight, fast and easy to use Node.js HTTP client
Stars: ✭ 20 (-60%)
Mutual labels:  patch
climate
The R climate package: an interface for downloading in-situ meteorological (and hydrological) dataset
Stars: ✭ 51 (+2%)
Mutual labels:  climate
godot-engine.code-snapshot
A plugin for Godot Engine which will let you take beautified snapshots of your code within the Editor. Configure the frame as you like, with GDScript syntax already highlighted.
Stars: ✭ 32 (-36%)
Mutual labels:  carbon
dwm-ipc
A DWM patch that allows IPC communication through a UNIX socket
Stars: ✭ 55 (+10%)
Mutual labels:  patch

Patch Ruby SDK

Test Gem Version Discord

The official Ruby gem for the Patch API

Documentation

For a complete API reference, check out Patch's API Reference.

Installation

Add the gem to your Gemfile:

gem 'patch_ruby'

Then run:

bundle

Or install it directly with

gem install patch_ruby

Requirements

  • Ruby 1.9+

Usage

Configuration

After installing the gem, you'll have to configure it with your API key which is available from the API key page in the Patch dashboard:

require 'patch_ruby'

Patch.configure do |config|
  # Configure the Patch gem with your API key here
  config.access_token = ENV['SANDBOX_API_KEY']
end

Orders

In Patch, orders represent a purchase of carbon offsets or negative emissions by mass. Place orders directly if you know the amount of carbon dioxide you would like to sequester. If you do not know how much to purchase, use an estimate.

You can also create an order with a maximum desired price, and we'll allocate enough mass to fulfill the order for you.

API Reference

Examples

# Create an order - you can create an order
# providing either mass_g or total_price_cents_usd, but not both

# Create order with mass
mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
Patch::Order.create_order(mass_g: mass)

# Create an order with maximum total price
total_price_cents_usd = 5_00 # Pass in the total price in cents (i.e. 5 dollars)
Patch::Order.create_order(total_price_cents_usd: total_price_cents_usd)

## You can also specify a project-id field (optional) to be used instead of the preferred one
project_id = 'pro_test_1234' # Pass in the project's ID
Patch::Order.create_order(mass_g: mass, project_id: project_id)

## Orders also accept a metadata field (optional)
metadata = {user: "john doe"}
Patch::Order.create_order(mass_g: mass, metadata: metadata)

# Retrieve an order
order_id = 'ord_test_1234' # Pass in the order's id
Patch::Order.retrieve_order(order_id)

# Place an order
order_id = 'ord_test_1234' # Pass in the order's id
Patch::Order.place_order(order_id)

# Cancel an order
order_id = 'ord_test_1234' # Pass in the order's id
Patch::Order.cancel_order(order_id)

# Retrieve a list of orders
page = 1 # Pass in which page of orders you'd like
Patch::Order.retrieve_orders(page: page)

Estimates

Estimates allow API users to get a quote for the cost of compensating a certain amount of CO2. When creating an estimate, an order in the draft state will also be created, reserving the allocation of a project for 5 minutes. If you don't place your draft order within those 5 minutes, the order will automatically be cancelled.

API Reference

Examples

# Create a mass estimate
mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
Patch::Estimate.create_mass_estimate(mass_g: mass)

# Create a flight estimate
distance_m = 1_000_000 # Pass in the distance traveled in meters
Patch::Estimate.create_flight_estimate(distance_m: distance_m)

# Create a shipping estimate
distance_m = 1_000_000 # Pass in the shipping distance in meters
package_mass_g = 10_000 # Pass in the weight of the package shipped in grams
transportation_method = "air" # Pass in the transportation method (air, rail, road, sea)
Patch::Estimate.create_shipping_estimate(
  distance_m: distance_m,
  package_mass_g: package_mass_g,
  transportation_method: transportation_method
)

# Create a vehicle estimate
distance_m = 1_000_000 # Pass in the shipping distance in meters
make = "Toyota" # Pass in the car make
model = "Corolla" # Pass in the car model
year = 2000 # Pass in the car year
Patch::Estimate.create_vehicle_estimate(
  distance_m: distance_m,
  make: make,
  model: model,
  year: year
)

# Create a flight estimate
transaction_value_btc_sats = 1000; # [Optional] Pass in the transaction value in satoshis
Patch::Estimate.create_bitcoin_estimate(transaction_value_btc_sats: transaction_value_btc_sats)

## You can also specify a project-id field (optional) to be used instead of the preferred one
project_id = 'pro_test_1234' # Pass in the project's ID
Patch::Estimate.create_mass_estimate(mass_g: mass, project_id: project_id)

# Retrieve an estimate
estimate_id = 'est_test_1234'
Patch::Estimate.retrieve_estimate(estimate_id)

# Retrieve a list of estimates
page = 1 # Pass in which page of estimates you'd like
Patch::Estimate.retrieve_estimates(page: page)

Projects

Projects are the ways Patch takes CO2 out of the air. They can represent reforestation, enhanced weathering, direct air carbon capture, etc. When you place an order via Patch, it is allocated to a project.

When fetching Projects, you can add filters to the query to narrow the result. Currently supported filters are:

  • country
  • type
  • minimum_available_mass

API Reference

Examples

# Retrieve a project
project_id = 'pro_test_1234' # Pass in the project's ID
Patch::Project.retrieve_project(project_id)

# Retrieve a list of projects
page = 1 # Pass in which page of projects you'd like
Patch::Project.retrieve_projects(page: page)

# Retrieve all projects from the United States
country = 'US'
Patch::Project.retrieve_projects(country: country)

# Retrieve all biomass projects
type = 'biomass'
Patch::Project.retrieve_projects(type: type)

# Retrieve a list of projects with at least 100 grams of available offsets
minimum_available_mass = 100
Patch::Project.retrieve_projects(minimum_available_mass: minimum_available_mass)

Contributing

While we value open-source contributions to this SDK, the core of this library is generated programmatically. Complex additions made directly to the library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README, as well as new test cases are always very welcome!

Testing locally

To build the gem locally, run:

gem build patch_ruby.gemspec

This will create a .gem file. To install the local gem:

gem install patch_ruby-1.x.x.gem

Running tests

Set up the required environment variable.

export SANDBOX_API_KEY=<SANDBOX API KEY>

then run the tests:

make test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].