Skip to content

basabin54/lob-ruby

 
 

Repository files navigation

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 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/

Requirements

Ruby

Getting Started

Registration

First, you will need to first create an account at Lob.com and obtain your Test and Live API Keys.

Once you have created an account, you can access your API Keys from the Settings Panel.

Installation & Usage

Install with the appropriate package manager.

Then add Lob's Ruby SDK to your Gemfile

gem install 'lob'

First API Call

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: "[email protected]",
    phone: "5555555555",
    address_line1: "210 King St",
    address_line2: "# 6100",
    address_city: "San Francisco",
    address_state: "CA",
    address_zip: "94107",
    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.

Testing

First, install RSpec 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:

$ bundle add rspec # with Bundler

$ gem install rspec # without Bundler

Unit Tests

$ 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:

$ LOB_API_TEST_KEY=<<YOUR TEST KEY>> LOB_API_LIVE_KEY=<<YOUR 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:

$ echo "LOB_API_TEST_KEY=<<YOUR TEST KEY>> LOB_API_LIVE_KEY=<<YOUR LIVE KEY>>" > LOCAL.env

Then, to run the integration tests:

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

About

Ruby Wrapper for Lob API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 99.9%
  • Shell 0.1%