Giter VIP home page Giter VIP logo

giftrocket-ruby's Introduction

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.
Giftrocket.configure do |config|
  config[:access_token] = 'YOUR_ACCESS_TOKEN_HERE'
  config[:base_api_uri] = 'https://testflight.giftrocket.com/api/v1/'
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

# Optionally pass a unique external_id for each order create call
# to guarantee that your order is idempotent and not executed multiple times.
external_id = "MY_UUID_FOR_THIS_ORDER"

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

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

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

giftrocket-ruby's People

Contributors

ben-rocket avatar bpless avatar kapilkale avatar nbaum5 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.