Class: Lancerkit
- Inherits:
-
Object
- Object
- Lancerkit
- Defined in:
- lib/lancerkit.rb
Instance Method Summary collapse
- #create_contact(data) ⇒ Object
- #create_document(data) ⇒ Object
- #delete_contacts(ids) ⇒ Object
- #delete_documents(ids) ⇒ Object
- #delete_transactions(ids) ⇒ Object
- #edit_contact(id, data) ⇒ Object
- #edit_document(id, data) ⇒ Object
- #edit_transaction(id, data) ⇒ Object
-
#initialize(api_key) ⇒ Lancerkit
constructor
A new instance of Lancerkit.
- #list_contacts(sort = '-date', page = 1) ⇒ Object
- #list_documents(sort = '-date', page = 1) ⇒ Object
- #list_transactions(sort = '-date', page = 1) ⇒ Object
Constructor Details
#initialize(api_key) ⇒ Lancerkit
6 7 8 |
# File 'lib/lancerkit.rb', line 6 def initialize(api_key) @api_key = api_key end |
Instance Method Details
#create_contact(data) ⇒ Object
26 27 28 |
# File 'lib/lancerkit.rb', line 26 def create_contact(data) self.edit_contact('new', data) end |
#create_document(data) ⇒ Object
22 23 24 |
# File 'lib/lancerkit.rb', line 22 def create_document(data) self.edit_document('new', data) end |
#delete_contacts(ids) ⇒ Object
46 47 48 |
# File 'lib/lancerkit.rb', line 46 def delete_contacts(ids) HTTParty.post(HOST + "/contacts/delete", {body: ids.to_json, headers: {authorization: @api_key, 'Content-Type': 'application/json'}}) end |
#delete_documents(ids) ⇒ Object
42 43 44 |
# File 'lib/lancerkit.rb', line 42 def delete_documents(ids) HTTParty.post(HOST + "/documents/delete", {body: ids.to_json, headers: {authorization: @api_key, 'Content-Type': 'application/json'}}) end |
#delete_transactions(ids) ⇒ Object
50 51 52 |
# File 'lib/lancerkit.rb', line 50 def delete_transactions(ids) HTTParty.post(HOST + "/transactions/delete", {body: ids.to_json, headers: {authorization: @api_key, 'Content-Type': 'application/json'}}) end |
#edit_contact(id, data) ⇒ Object
34 35 36 |
# File 'lib/lancerkit.rb', line 34 def edit_contact(id, data) HTTParty.get(HOST + "/contacts/#{id}", {body: data.to_json, headers: {authorization: @api_key, 'Content-Type': 'application/json'}}) end |
#edit_document(id, data) ⇒ Object
30 31 32 |
# File 'lib/lancerkit.rb', line 30 def edit_document(id, data) HTTParty.get(HOST + "/documents/#{id}", {body: data.to_json, headers: {authorization: @api_key, 'Content-Type': 'application/json'}}) end |
#edit_transaction(id, data) ⇒ Object
38 39 40 |
# File 'lib/lancerkit.rb', line 38 def edit_transaction(id, data) HTTParty.get(HOST + "/transactions/#{id}", {body: data.to_json, headers: {authorization: @api_key, 'Content-Type': 'application/json'}}) end |
#list_contacts(sort = '-date', page = 1) ⇒ Object
14 15 16 |
# File 'lib/lancerkit.rb', line 14 def list_contacts(sort='-date', page=1) HTTParty.get(HOST + "/contacts", {query: {sort:sort, page: page}, headers: {authorization: @api_key}}) end |
#list_documents(sort = '-date', page = 1) ⇒ Object
10 11 12 |
# File 'lib/lancerkit.rb', line 10 def list_documents(sort='-date', page=1) HTTParty.get(HOST + "/documents", {query: {sort:sort, page: page}, headers: {authorization: @api_key}}) end |
#list_transactions(sort = '-date', page = 1) ⇒ Object
18 19 20 |
# File 'lib/lancerkit.rb', line 18 def list_transactions(sort='-date', page=1) HTTParty.get(HOST + "/transactions", {query: {sort:sort, page: page}, headers: {authorization: @api_key}}) end |