Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/psibi/stickystamp-ruby

Ruby API Library for StickyStamp
https://github.com/psibi/stickystamp-ruby

Last synced: 13 days ago
JSON representation

Ruby API Library for StickyStamp

Awesome Lists containing this project

README

        

stickystamp-ruby
-----------------

A Ruby interface for StickyStamp API.

Usage
------

The library makes it simple to interact with Stickystamp REST API. Let
me demonstrate it through a sample `irb` session:

>>> require 'stickystamp'
=> true

This means you have installed the gem properly and are ready to go!
Now create a `StickyStamp` object. This object will be used for all
the interaction with the StickyStamp servers.

>>> api = StickyStamp.new("b79bdeaa19f147afbbe2d7ef9dee9be2")
=> API Key: b79bdeaa19f147afbbe2d7ef9dee9be2

You pass an API key for creating a stickystamp object.
Now you can create a sample recipient object like this:

>>> r = Recipient.new("isaac","[email protected]","12, Krishnan Street","West Mambalam","Chennai","Tamilnadu","India","600033","888888888")
=> isaac [email protected]

To create it in the server, all you have to do is:

>>> recipient = api.createRecipient(r)
=> isaac [email protected]

Now you can inspect that recipient object:

>>> recipient.id
=> 33

You can also get information about a specific recipient, if you kwow
it's id:

>>> another_recipient = api.getSpecificRecipient(33)
=> isaac [email protected]
>>> another_recipient.email
=> "[email protected]"
>>> another_recipient.country
=> "India"

To get the list of all shipments:

>>> api.getShipments
=> [352, 354, 371, 448, 454, 593, 597, 670, 733, 734, 779, 792]

Note that each list we got above is an object internally:

>>> shipments = api.getShipments
=> [352, 354, 371, 448, 454, 593, 597, 670, 733, 734, 779, 792]
>>> shipments[4].tax
=> "0.00"

To get an information about specific shipment:

>>> shipment_371 = api.getSpecificShipment "371"
=> 371
>>> shipment_371.recipient["email"]
=> "[email protected]"

Similarly you can get all the getGrantForms:

>>> api.getGrantForms
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]

You can play around with each of the objects:

>>> gforms = api.getGrantForms
=>
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
>>> gforms[0].id
=> 1
>>> gforms[0].url
=> "http://beta.stickystamp.com/shiptokens/convert/95d9cf352d994e67820060930fb055f8"

To get a specific grantform:

>>> gform_10 = api.getSpecificGrantForm "10"
=> 10
>>> gform_10.url
=> "http://beta.stickystamp.com/shiptokens/convert/810cc9a6301c491b84a352ccf0e48ecb"

To get the list of all Merchandise:

>>> api.getAllMerchandise
=> [Campus Hero :tshirt, Code Ninja :tshirt, Thank You Card :postcard, Smashing Logo :sticker, Awesome Logo :sticker, Hacker :tshirt]

Note that every item in the list is an `object`. So you can play with
them individually:

>>> b = api.getAllMerchandise
=> [Campus Hero :tshirt, Code Ninja :tshirt, Thank You Card :postcard, Smashing Logo :sticker, Awesome Logo :sticker, Hacker :tshirt]
>>> b[0]
=> Campus Hero :tshirt
>>> b[0].id
=> "T1-CMPSH"

To get information about specific merchandise:

>>> tshirt_merchandise = api.getSpecificMerchandise "T1-CMPSH"
=> Campus Hero :tshirt
>>> tshirt_merchandise.tshirt_type
=> "Cotton Roundneck"

Isn't that beautiful?

License
--------

MIT