https://github.com/lob/lob-ruby
Ruby Wrapper for Lob API
https://github.com/lob/lob-ruby
Last synced: 8 months ago
JSON representation
Ruby Wrapper for Lob API
- Host: GitHub
- URL: https://github.com/lob/lob-ruby
- Owner: lob
- License: mit
- Created: 2013-07-07T16:29:01.000Z (over 12 years ago)
- Default Branch: main
- Last Pushed: 2024-03-01T20:25:52.000Z (almost 2 years ago)
- Last Synced: 2024-04-14T10:12:30.846Z (over 1 year ago)
- Language: Ruby
- Homepage: lob.com
- Size: 5.62 MB
- Stars: 97
- Watchers: 62
- Forks: 44
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lob-ruby-sdk
The Lob API is organized around REST. Our API is designed to have predictable, resource-oriented URLs and uses HTTP response codes to indicate any API errors.
This Ruby package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
- API version: 1.3.0
- Package version: 1.0.0
- Build package: org.openapitools.codegen.languages.RubyClientCodegen
For more information, please visit [https://support.lob.com/](https://support.lob.com/)
## Requirements
Ruby
## Getting Started
### Registration
First, you will need to first create an account at [Lob.com](https://dashboard.lob.com/#/register) and obtain your Test and Live API Keys.
Once you have created an account, you can access your API Keys from the [Settings Panel](https://dashboard.lob.com/#/settings).
### Installation & Usage
Install with the appropriate [package manager](https://www.ruby-lang.org/en/documentation/installation/#winget).
Then add Lob's Ruby SDK to your Gemfile
```ruby
gem install 'lob'
```
## First API Call
```ruby
require 'lob'
config = Lob::Configuration.default
config.username = ENV['LOB_API_TEST_KEY']
apiInstance = Lob::AddressesApi.new
addressEditable = Lob::AddressEditable.new({
description: "Harry - Office",
name: "Harry Zhang",
company: "Lob",
email: "harry@lob.com",
phone: "5555555555",
address_line1: "2261 Market Street",
address_line2: "Ste 5668",
address_city: "San Francisco",
address_state: "CA",
address_zip: "94114",
address_country: "US",
});
begin
#create
result = apiInstance.create(addressEditable)
p result
rescue Lob::ApiError => e
puts "Exception when calling AddressesApi->create: #{e}"
end
```
## API Documentation
The full and comprehensive documentation of Lob's APIs is available [here](https://docs.lob.com/).
## Testing
First, install [RSpec](https://rspec.info/) to run the tests. This can be done by running either of the following lines on your command line depending on whether you use Bundler:
```shell
$ bundle add rspec # with Bundler
$ gem install rspec # without Bundler
```
### Unit Tests
```bash
$ rspec -P __tests__/Api/* --color --format doc
```
### Integration Tests
Integration tests run against a live deployment of the Lob API and require multiple valid API keys with access to specific features. As such, it is not expected that these tests will pass for every user in every environment.
To run integration tests:
```bash
$ LOB_API_TEST_KEY=<> LOB_API_LIVE_KEY=<> rspec -P __tests__/Integration/* --color --format doc
```
#### A cleaner alternative if you are going to run integration tests frequently
Run this the first time:
```bash
$ echo "LOB_API_TEST_KEY=<> LOB_API_LIVE_KEY=<>" > LOCAL.env
```
Then, to run the integration tests:
```bash
$ env $(cat LOCAL.env) rspec -P __tests__/Integration/* --color --format doc
```
=======================
Copyright © 2022 Lob.com
Released under the MIT License, which can be found in the repository in [LICENSE.txt](https://github.com/lob/lob-go/blob/main/LICENSE.txt).