Class: Trolley::InvoiceGateway

Inherits:
Object
  • Object
show all
Defined in:
lib/trolley/gateways/InvoiceGateway.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ InvoiceGateway

Returns a new instance of InvoiceGateway.



5
6
7
# File 'lib/trolley/gateways/InvoiceGateway.rb', line 5

def initialize(client)
  @client = client
end

Instance Method Details

#create(body) ⇒ Object



14
15
16
17
# File 'lib/trolley/gateways/InvoiceGateway.rb', line 14

def create(body)
  response = @client.post('/v1/invoices/create', body)
  invoice_builder(response)
end

#create_line(body) ⇒ Object



19
20
21
22
# File 'lib/trolley/gateways/InvoiceGateway.rb', line 19

def create_line(body)
  response = @client.post('/v1/invoices/create-lines', body)
  invoice_builder(response)
end

#delete(body) ⇒ Object



39
40
41
42
# File 'lib/trolley/gateways/InvoiceGateway.rb', line 39

def delete(body)
  @client.post('/v1/invoices/delete', body)
  true
end

#delete_line(body) ⇒ Object



44
45
46
47
# File 'lib/trolley/gateways/InvoiceGateway.rb', line 44

def delete_line(body)
  @client.post('/v1/invoices/delete-lines', body)
  true
end

#find(body) ⇒ Object



9
10
11
12
# File 'lib/trolley/gateways/InvoiceGateway.rb', line 9

def find(body)
  response = @client.post('/v1/invoices/get', body)
  invoice_builder(response)
end

#invoice_builder(response) ⇒ Object



49
50
51
# File 'lib/trolley/gateways/InvoiceGateway.rb', line 49

def invoice_builder(response)
  Utils::ResponseMapper.build(response, Invoice)
end

#invoice_list_builder(response) ⇒ Object



53
54
55
# File 'lib/trolley/gateways/InvoiceGateway.rb', line 53

def invoice_list_builder(response)
  Utils::PaginatedArray.from_response(response, Invoice)
end

#search(body) ⇒ Object



24
25
26
27
# File 'lib/trolley/gateways/InvoiceGateway.rb', line 24

def search(body)
  response = @client.post('/v1/invoices/search', body)
  invoice_list_builder(response)
end

#update(body) ⇒ Object



29
30
31
32
# File 'lib/trolley/gateways/InvoiceGateway.rb', line 29

def update(body)
  @client.post('/v1/invoices/update', body)
  true
end

#update_line(body) ⇒ Object



34
35
36
37
# File 'lib/trolley/gateways/InvoiceGateway.rb', line 34

def update_line(body)
  @client.post('/v1/invoices/update-lines', body)
  true
end