A gem to send physical mail with the Seeuletter.com API.
Switch branches/tags
Nothing to show
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Bumping to 1.1.0 - New endpoint Price Feb 1, 2018
lib Bumping to 1.1.0 - New endpoint Price Feb 1, 2018
.gitignore First commit Nov 10, 2017
Gemfile First commit Nov 10, 2017
LICENSE.txt First commit Nov 10, 2017
README.md Add dependency status badge May 14, 2018
Rakefile First commit Nov 10, 2017
seeuletter.gemspec First commit Nov 10, 2017

README.md

seeuletter-ruby

Gem Version Dependency Status

Ruby wrapper for the Seeuletter.com API. See the full Seeuletter.com API Documentation. For best results, be sure that you're using the latest version of the Seeuletter API and the latest version of the ruby wrapper. This gem gives you an ActiveRecord-style syntax to use the Seeuletter.com API.

Supports Ruby 2.0.0 and greater.

Table of Contents

Getting Started

Here's a general overview of the Seeuletter services available, click through to read more.

Please read through the official API Documentation to get a complete sense of what to expect from each endpoint.

Registration

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

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

Installation

Add this line to your application's Gemfile:

gem 'seeuletter'

And then execute:

$ bundle

Or manually install it yourself:

$ gem install seeuletter

Usage

The library uses an ActiveRecord-style interface.

For optional parameters and other details, refer to the docs here.

Initialization and Configuration

# To initialize a Seeuletter object
seeuletter = Seeuletter::Client.new(api_key: "your-api-key")

Create a new letter

# send the letter
require 'seeuletter'

# initialize Seeuletter object
seeuletter = Seeuletter::Client.new(api_key: '<PUT_YOU_API_KEY_HERE>')

puts seeuletter.letters.create(
  description: "Test letter from the Ruby Wrapper",
  to: {
    name: 'Erlich',
    address_line1: '30 rue de rivoli',
    address_line2: '',
    address_city: 'Paris',
    address_country: 'France',
    address_postalcode: '75004'
  },
  source_file: '<html>Hello {{name}}</html>',
  source_file_type: 'html',
  postage_type: 'prioritaire',
  variables: { name: 'Erlich'},
  color: 'color'
)

List all letters

require 'seeuletter'

seeuletter = Seeuletter::Client.new(api_key: 'test_12345678901234567890')

puts seeuletter.letters.list()

Get a specific letter

require 'seeuletter'

seeuletter = Seeuletter::Client.new(api_key: 'test_12345678901234567890')

puts seeuletter.letters.find('LETTER_ID')

Get the price of a letter

require 'seeuletter'

seeuletter = Seeuletter::Client.new(api_key: 'test_12345678901234567890')

puts seeuletter.letter_price.get(color: 'bw', postage_type: 'prioritaire', postage_speed: 'D1', page_count: 1)

Caution: Pass zero-prefixed postal codes as strings

When using postal codes with zero-prefixes, always quote them. For example when specifying 02125, pass it as a string "02125", instead of an integer.

The Ruby interpreter assumes it's not of base-10 and tries to convert it to base-10 number. So that might result in an entirely different postal code than intended.

Accessing Response Headers

You can access response headers via a hidden headers method on the response hash.

addresses = seeuletter.addresses.list

addresses._response.headers[:content_type]
# => "application/json"

Examples

We've provided various examples for you to try out here.

There are simple scripts to demonstrate how to create all letters with the Seeuletter API Ruby wrapper.

=======================

Copyright © 2017 Seeuletter.com

Released under the MIT License, which can be found in the repository in LICENSE.txt.