Coder Social home page Coder Social logo

aws_agcod's Introduction

AGCOD

Build Status Gem Version

Amazon Gift Code On Demand (AGCOD) API v2 implementation for distribute Amazon gift cards (gift codes) instantly in any denomination.

Installation

Add this line to your application's Gemfile:

gem 'aws_agcod'

And then execute:

$ bundle

Or install it yourself as:

$ gem install aws_agcod

Usage

Configure

require "aws_agcod"

AGCOD.configure do |config|
  config.access_key = "YOUR ACCESS KEY"
  config.secret_key = "YOUR SECRET KEY"
  config.partner_id = "PARTNER ID"

  # The `production` config is important as it determines which endpoint
  # you're hitting.
  config.production = true  # This defaults to false.

  # Optionally, you can customize the URI completely.
  config.uri = "https://my-custom-agcod-endpoint.com"

  config.region  = "us-east-1" # default
  config.timeout = 30          # default
end

Create Gift Code/Card

request_id = "test"
amount = 10
currency = "USD" # default to USD, available types are: USD, EUR, JPY, CNY, CAD

request = AGCOD::CreateGiftCard.new(request_id, amount, currency)

# When succeed
if request.success?
  request.claim_code # => code for the gift card
  request.gc_id # => gift card id
  request.request_id # => your request id
else
# When failed
  request.error_message # => Error response from AGCOD service
end

Cancel Gift Code/Card

request_id = "test"
gc_id = "test_gc_id"

request = AGCOD::CancelGiftCard.new(request_id, gc_id)

# When failed
unless request.success?
  request.error_message # => Error response from AGCOD service
end

Get Gift Code/Card activities

request_id = "test"
start_time = Time.now - 86400
end_time = Time.now
page = 1
per_page = 100
show_no_ops = false # Whether or not to show activities with no operation

request = AGCOD::GiftCardActivityList.new(request_id, start_time, end_time, page, per_page, show_no_ops)

if request.success?
  request.results.each do |activity|
    activity.status # => SUCCESS, FAILURE, RESEND
    activity.created_at
    activity.type
    activity.card_number
    activity.amount
    activity.error_code
    activity.gc_id
    activity.partner_id
    activity.request_id
  end
else
  request.error_message # => Error response from AGCOD service
end

Contributing

  1. Fork it ( https://github.com/[my-github-username]/aws_agcod/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

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.