README.md in patch_ruby-1.0.0 vs README.md in patch_ruby-1.1.0
- old
+ new
@@ -1,8 +1,9 @@
# Patch Ruby SDK
![Test](https://github.com/patch-technology/patch-ruby/workflows/Test/badge.svg)
[![Gem Version](https://badge.fury.io/rb/patch_ruby.svg)](https://badge.fury.io/rb/patch_ruby)
+[![Discord](https://img.shields.io/discord/733029448558837792)](https://discord.gg/AU8543D)
The official Ruby gem for the [Patch API](https://www.usepatch.com)
## Documentation
For a complete API reference, check out [Patch's API Reference.](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml)
@@ -50,10 +51,18 @@
```ruby
# Create an order
mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
Patch::Order.create_order(mass_g: mass)
+## 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
@@ -78,10 +87,14 @@
```ruby
# Create an estimate
mass = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
Patch::Estimate.create_mass_estimate(mass_g: mass)
+## 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
@@ -104,11 +117,11 @@
page = 1 # Pass in which page of projects you'd like
Patch::Project.retrieve_projects(page: page)
```
### Preferences
-Preferences are how you route your orders in Patch. If you don't have a preference, Patch will allocate your order to the least expensive option. If you do have a preference, all of your orders will be sent to that project. You can set your preferences via API, or through the [Patch Dashboard](dashboard.usepatch.com/projects).
+Preferences are how you route your orders in Patch. If you don't have a preference, Patch will allocate your order to the least expensive option. If you do have a preference, all of your orders will be sent to that project. You can set your preferences via API, or through the [Patch Dashboard](https://dashboard.usepatch.com/projects).
[API Reference](https://docs.usepatch.com/docs/patch/openapi/v1/swagger.yaml/paths/~1v1~1preferences/post)
#### Examples
```ruby
@@ -125,6 +138,33 @@
Patch::Preference.delete_preference(preference_id)
# Retrieve a list of preferences
page = 1 # Pass in which page of preferences you'd like
Patch::Preference.retrieve_preferences(page: page)
+```
+
+## Development
+
+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
+```
+
+Install dependencies:
+```
+$ bundle install
+```
+
+Set up required environment variables:
+```
+$ export PATCH_RUBY_API_KEY=<SANDBOX API KEY>
+```
+
+Run tests:
+```
+$ bundle exec rspec
```