Class: Briq
Instance Method Summary collapse
- #create_transaction(from = '', to = '', amount = 1, comment = 'congrats', query = {}) ⇒ Object
- #delete_transaction(transaction_id) ⇒ Object
- #get_group(group_id) ⇒ Object
- #get_organization ⇒ Object
- #get_transaction(transaction_id) ⇒ Object
- #get_user(user_id) ⇒ Object
-
#initialize(access_token = nil, org_name = nil) ⇒ Briq
constructor
A new instance of Briq.
- #list_groups(per_page = 100, page = 1) ⇒ Object
- #list_transactions(per_page = 100, page = 1) ⇒ Object
- #list_users(per_page = 100, page = 1) ⇒ Object
Constructor Details
#initialize(access_token = nil, org_name = nil) ⇒ Briq
Returns a new instance of Briq.
9 10 11 12 13 14 15 |
# File 'lib/briq.rb', line 9 def initialize(access_token=nil, org_name=nil) # @access_token = access_token @base_uri = "https://www.givebriq.com/v0/organizations/" @org_name = URI.escape(org_name) @auth = {:username => access_token, :password => ""} @headers = {"Content-Type": "application/json"} end |
Instance Method Details
#create_transaction(from = '', to = '', amount = 1, comment = 'congrats', query = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/briq.rb', line 48 def create_transaction(from='', to='', amount = 1, comment = 'congrats', query = {}) if from == '' && to == '' raise ArgumentError.new('Need at least a sender or a receiver') elsif comment == '' raise ArgumentError.new('Need a comment along with the briqs') end opts = {'from': from , 'to': to, 'amount': amount, 'comment': comment} p opts make_request '/transactions', 'post', query = query, body = opts end |
#delete_transaction(transaction_id) ⇒ Object
59 60 61 |
# File 'lib/briq.rb', line 59 def delete_transaction(transaction_id) make_request "/transactions/#{transaction_id}", 'delete' end |
#get_group(group_id) ⇒ Object
35 36 37 |
# File 'lib/briq.rb', line 35 def get_group(group_id) make_request "/groups/#{group_id}", 'get' end |
#get_organization ⇒ Object
17 18 19 |
# File 'lib/briq.rb', line 17 def get_organization make_request '', 'get' end |
#get_transaction(transaction_id) ⇒ Object
44 45 46 |
# File 'lib/briq.rb', line 44 def get_transaction(transaction_id) make_request "/transactions/#{transaction_id}", 'get' end |
#get_user(user_id) ⇒ Object
26 27 28 |
# File 'lib/briq.rb', line 26 def get_user(user_id) make_request "/users/#{user_id}", 'get' end |
#list_groups(per_page = 100, page = 1) ⇒ Object
30 31 32 33 |
# File 'lib/briq.rb', line 30 def list_groups(per_page = 100, page = 1) opts = {'per_page': per_page , 'page': page} make_request '/groups', 'get', query = opts end |
#list_transactions(per_page = 100, page = 1) ⇒ Object
39 40 41 42 |
# File 'lib/briq.rb', line 39 def list_transactions(per_page = 100, page = 1) opts = {'per_page': per_page , 'page': page} make_request '/transactions', 'get', query = opts end |
#list_users(per_page = 100, page = 1) ⇒ Object
21 22 23 24 |
# File 'lib/briq.rb', line 21 def list_users(per_page = 100, page = 1) opts = {'per_page': per_page , 'page': page} make_request '/users', 'get', query = opts end |