Class: Sydecar::Expense
- Inherits:
-
Object
- Object
- Sydecar::Expense
- Defined in:
- lib/sydecar/expense.rb
Constant Summary collapse
- URL =
'/v1/expenses'
- CREATE_URL =
"#{URL}/create"
Class Method Summary collapse
- .cancel(id:) ⇒ Object
- .cancel_url(id:) ⇒ Object
- .create(body:) ⇒ Object
- .delete(id:) ⇒ Object
- .find(id:) ⇒ Object
-
.find_all(params: {}, body: {}) ⇒ Object
- String
-
sort: asc / desc [Integer] limit [Integer] offset [String] start_date (format: yyyy-mm-dd) [String] end_date (format: yyyy-mm-dd).
- .pay(id:) ⇒ Object
- .pay_url(id:) ⇒ Object
- .update(id:, body:) ⇒ Object
Class Method Details
.cancel(id:) ⇒ Object
55 56 57 58 |
# File 'lib/sydecar/expense.rb', line 55 def cancel(id:) url = cancel_url(id: id) Connection.instance.post(url) end |
.cancel_url(id:) ⇒ Object
51 52 53 |
# File 'lib/sydecar/expense.rb', line 51 def cancel_url(id:) "/v1/expenses/#{id}/cancel" end |
.create(body:) ⇒ Object
9 10 11 |
# File 'lib/sydecar/expense.rb', line 9 def create(body:) Connection.instance.post(CREATE_URL, body) end |
.delete(id:) ⇒ Object
38 39 40 |
# File 'lib/sydecar/expense.rb', line 38 def delete(id:) Connection.instance.delete("#{URL}/#{id}") end |
.find(id:) ⇒ Object
14 15 16 |
# File 'lib/sydecar/expense.rb', line 14 def find(id:) Connection.instance.get("#{URL}/#{id}", { reveal_pii: true }) end |
.find_all(params: {}, body: {}) ⇒ Object
- String
-
sort: asc / desc
- Integer
-
limit
- Integer
-
offset
- String
-
start_date (format: yyyy-mm-dd)
- String
-
end_date (format: yyyy-mm-dd)
31 32 33 34 35 |
# File 'lib/sydecar/expense.rb', line 31 def find_all(params: {}, body: {}) query = '?' query += URI.encode_www_form(params) Connection.instance.post("#{URL}#{query}", body) end |
.pay(id:) ⇒ Object
46 47 48 49 |
# File 'lib/sydecar/expense.rb', line 46 def pay(id:) url = pay_url(id: id) Connection.instance.post(url) end |
.pay_url(id:) ⇒ Object
42 43 44 |
# File 'lib/sydecar/expense.rb', line 42 def pay_url(id:) "/v1/expenses/#{id}/pay" end |
.update(id:, body:) ⇒ Object
20 21 22 |
# File 'lib/sydecar/expense.rb', line 20 def update(id:, body:) Connection.instance.patch("#{URL}/#{id}", body) end |