https://github.com/mango/mango-ruby
This is the Ruby library that allows interaction with Mango API
https://github.com/mango/mango-ruby
Last synced: 12 months ago
JSON representation
This is the Ruby library that allows interaction with Mango API
- Host: GitHub
- URL: https://github.com/mango/mango-ruby
- Owner: Mango
- License: mit
- Created: 2014-12-01T16:51:24.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-07-20T14:55:26.000Z (almost 11 years ago)
- Last Synced: 2025-05-13T19:58:33.552Z (about 1 year ago)
- Language: Ruby
- Homepage: https://developers.getmango.com/en/api/?platform=ruby
- Size: 160 KB
- Stars: 8
- Watchers: 7
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Mango
=====
Ruby wrapper for Mango API
## Description
API to interact with Mango
https://getmango.com/
## Installation
As usual, you can install it using rubygems.
```
$ gem install mango-ruby
```
## Usage
```
require 'mango-ruby'
Mango.api_key = ENV['MANGO_SECRET_KEY']
params = {
email: "johndoe@example.com",
name: "John Doe"
}
begin
customer = Mango::Customers.create params
rescue Mango::Error => e
e.each {|code, message| ... }
end
```
You can set a global API_KEY (`Mango.api_key`) or override it on each request
## API
All the requests go through:
```
Mango.request(method, url, api_key=nil, params={}, headers={})
```
But you can use CRUD methods on `Mango::Cards`, `Mango::Customers`...
```
def create params={}, api_key=nil
def list params={}, api_key=nil
def retrieve uid, params={}, api_key=nil
def delete uid, params={}, api_key=nil
def update uid, params={}, api_key=nil
```
So these two are equivalent:
```
customer = Mango::Customers.create params
customer = Mango.request :post, '/customers/', api_key, params
```
These are the operations available for each resource:
|Resource|list|create|retrieve|update|delete|delete_all|
|--------|:--:|:----:|:------:|:----:|:----:|:--------:|
|Cards | x | x | x | x | x | |
|Charges | x | x | x | | | |
|Customers | x | x | x | x | x | |
|Installments | x | | | | | |
|Queue | x | x | x | | x | x |
|Refunds | x | x | x | | | |
|Promotions | x | | x | | | |
|Coupons | x | x | x | x | | |