Official GiftRocket Gift Card Ruby API
Ruby
Latest commit 3b304f2 Dec 28, 2016 @kapilkale kapilkale more readme
Permalink
Failed to load latest commit information.
lib Allow querying the gift endpoint Dec 28, 2016
test Allow querying the gift endpoint Dec 28, 2016
.gitignore
Gemfile
LICENSE docs and license Dec 28, 2016
README.md
Rakefile
giftrocket.gemspec

README.md

GiftRocket Gift Card Ruby API

Installation

$ gem install 'giftrocket_ruby'

or, add to your Gemfile

source 'https://rubygems.org'
gem 'giftrocket_ruby'

Usage

require 'giftrocket'

# Configure with your sandbox / production token.
ACCESS_TOKEN = 'YOUR_ACCESS_TOKEN_HERE'
Giftrocket.configure do |config|
  config[:access_token] = ACCESS_TOKEN
end

funding_sources = Giftrocket::FundingSource.list
styles = Giftrocket::Style.list
orders = Giftrocket::Order.list # blank at first.
gifts = Giftrocket::Gift.list # blank at first.

#
# Generate an order.
#

# The funding source you select is how you are charged for the order.
funding_source_id = funding_sources.first.id

# An array data representing the gifts you'd like to send.
gifts_data = [
  {
    "amount": 30,
    "message": "Thanks for your help this year!",
    "style_id": styles.first.id,
    "recipient": {
      "email": "jake@giftrocket.com",
      "name": "Jake Douglas"
    }
  }
]

# Submit the order to GiftRocket.
order = Giftrocket::Order.create!(funding_source_id, gifts_data)

# Retrieve the order and gift.
Giftrocket::Order.retrieve(order.id)
Giftrocket::Gift.retrieve(order.gifts.first.id)

Contributing

The gem is maintained by GiftRocket engineers, but all are welcome to contribute. Feel free to open an issue, submit a PR, or post a question.