|
1 | | -# patch_ruby |
| 1 | +# Patch ruby |
| 2 | + |
2 | 3 |
|
3 | | -PatchRuby - the Ruby gem for the Patch API V1 |
| 4 | +The official Ruby gem for the [Patch API](https://www.usepatch.com) |
4 | 5 |
|
5 | | -The core API used to integrate with Patch's service |
| 6 | +## Documentation |
6 | 7 |
|
7 | | -This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project: |
8 | | - |
9 | | -- API version: v1 |
10 | | -- Package version: 1.0.0 |
11 | | -- Build package: org.openapitools.codegen.languages.RubyClientCodegen |
| 8 | +For detailed documentation and examples, see the [Patch API docs](https://www.usepatch.com). |
12 | 9 |
|
13 | 10 | ## Installation |
14 | 11 |
|
15 | | -### Build a gem |
16 | | - |
17 | | -To build the Ruby code into a gem: |
18 | | - |
19 | | -```shell |
20 | | -gem build patch_ruby.gemspec |
| 12 | +Add the gem to your Gemfile: |
| 13 | +```ruby |
| 14 | +gem 'patch_ruby' |
21 | 15 | ``` |
22 | 16 |
|
23 | | -Then either install the gem locally: |
24 | | - |
| 17 | +Then run: |
25 | 18 | ```shell |
26 | | -gem install ./patch_ruby-1.0.0.gem |
| 19 | +bundle |
27 | 20 | ``` |
28 | 21 |
|
29 | | -(for development, run `gem install --dev ./patch_ruby-1.0.0.gem` to install the development dependencies) |
30 | | - |
31 | | -or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/). |
32 | | - |
33 | | -Finally add this to the Gemfile: |
34 | | - |
35 | | - gem 'patch_ruby', '~> 1.0.0' |
36 | | - |
37 | | -### Install from Git |
38 | | - |
39 | | -If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile: |
40 | | - |
41 | | - gem 'patch_ruby', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git' |
42 | | - |
43 | | -### Include the Ruby code directly |
44 | | - |
45 | | -Include the Ruby code directly using `-I` as follows: |
46 | | - |
| 22 | +Or install it directly with |
47 | 23 | ```shell |
48 | | -ruby -Ilib script.rb |
| 24 | +gem install patch_ruby |
49 | 25 | ``` |
50 | 26 |
|
51 | | -## Getting Started |
| 27 | +### Requirements |
| 28 | +- Ruby 1.9+ |
52 | 29 |
|
53 | | -Please follow the [installation](#installation) procedure and then run the following code: |
| 30 | +## Usage |
54 | 31 |
|
| 32 | +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: |
55 | 33 | ```ruby |
56 | | -# Load the gem |
57 | 34 | require 'patch_ruby' |
58 | 35 |
|
59 | | -# Setup authorization |
60 | 36 | PatchRuby.configure do |config| |
61 | | - # Configure Bearer authorization: bearer_auth |
62 | | - config.access_token = 'YOUR_BEARER_TOKEN' |
| 37 | + # Configure the Patch gem with your API key here |
| 38 | + config.access_token = 'key_test_1234' |
63 | 39 | end |
| 40 | +``` |
64 | 41 |
|
65 | | -api_instance = PatchRuby::OrdersApi.new |
66 | | -id = 'id_example' # String | |
| 42 | +Once configured, you can test it out: |
| 43 | +```ruby |
| 44 | +# Retrieve and print all your orders |
| 45 | +orders_api = PatchRuby::OrdersApi.new |
67 | 46 |
|
68 | 47 | begin |
69 | | - #Cancel an order |
70 | | - result = api_instance.cancel_order(id) |
71 | | - p result |
| 48 | + orders_response = orders_api.retrieve_orders |
| 49 | + |
| 50 | + orders_response.data.each do |order| |
| 51 | + puts "Order ID: #{order.id}, Order State: #{order.state}" |
| 52 | + end |
| 53 | +# Rescue from any Patch API errors |
72 | 54 | rescue PatchRuby::ApiError => e |
73 | | - puts "Exception when calling OrdersApi->cancel_order: #{e}" |
| 55 | + puts "Failed to retrieve Orders with status code #{e.code}: #{e.message}" |
74 | 56 | end |
| 57 | +``` |
75 | 58 |
|
| 59 | +## Development |
| 60 | + |
| 61 | +Install dependencies: |
| 62 | +```shell |
| 63 | +bundle install --path vendor/bundle |
| 64 | +``` |
| 65 | + |
| 66 | +Run tests: |
| 67 | +```shell |
| 68 | +bundle exec rspec |
| 69 | +``` |
| 70 | + |
| 71 | +Building and installing the gem locally: |
| 72 | +```shell |
| 73 | +gem build patch_ruby.gemspec |
| 74 | +gem install patch_ruby-<version>.gem |
76 | 75 | ``` |
77 | 76 |
|
78 | 77 | ## Documentation for API Endpoints |
@@ -108,11 +107,3 @@ Class | Method | HTTP request | Description |
108 | 107 | - [PatchRuby::ProjectListResponse](docs/ProjectListResponse.md) |
109 | 108 | - [PatchRuby::ProjectResponse](docs/ProjectResponse.md) |
110 | 109 |
|
111 | | - |
112 | | -## Documentation for Authorization |
113 | | - |
114 | | - |
115 | | -### bearer_auth |
116 | | - |
117 | | -- **Type**: Bearer authentication |
118 | | - |
0 commit comments