Class: Alegra::Payments

Inherits:
Record
  • Object
show all
Defined in:
lib/alegra/payments.rb

Instance Attribute Summary

Attributes inherited from Record

#client

Instance Method Summary collapse

Methods inherited from Record

#initialize

Constructor Details

This class inherits a constructor from Alegra::Record

Instance Method Details

#create(params) ⇒ Hash

Creates a payment

Parameters:

  • params (Hash)
    • date [ String ]

    • bank_account [ Integer ] or [ Hash ]

    • payment_method [ String ]

    • observations [ String ]

    • anotation [ String ]

    • type [ String ]

    • client [ Integer ] or [ Hash ]

    • invoices [ Array ]

    • bills [ Array ]

    • categories [ Array ]

    • retentions [ Array ]

    • currency [ Array ]

Returns:



38
39
40
41
# File 'lib/alegra/payments.rb', line 38

def create(params)
  sanitize_params = params.deep_camel_case_lower_keys
  client.post('payments', sanitize_params)
end

#delete(id) ⇒ Hash

Parameters:

  • id (Integer)

Returns:



66
67
68
# File 'lib/alegra/payments.rb', line 66

def delete(id)
  client.delete("payments/#{id}")
end

#find(id) ⇒ Hash

Parameters:

  • id (Integer)

Returns:



5
6
7
# File 'lib/alegra/payments.rb', line 5

def find(id)
  client.get("payments/#{id}")
end

#list(params = {}) ⇒ Array

Returs all payments

Parameters:

  • params (Hash) (defaults to: {})
    • start [ Integer ]

    • limit [ Integer ]

    • order_direction [ String ]

    • order_field [ string ]

    • type [ Integer ]

    • metadata [ Boolean ]

    • id [ Integer ]

Returns:



19
20
21
# File 'lib/alegra/payments.rb', line 19

def list(params = {})
  client.get('payments', params)
end

#update(id, params) ⇒ Hash

Update a payment

Parameters:

  • id (Integer)
  • params (Hash)
    • date [ String ]

    • bank_account [ Integer ] or [ Hash ]

    • payment_method [ String ]

    • observations [ String ]

    • anotation [ String ]

    • type [ String ]

    • client [ Integer ] or [ Hash ]

    • invoices [ Array ]

    • bills [ Array ]

    • categories [ Array ]

    • retentions [ Array ]

    • currency [ Array ]

Returns:



59
60
61
62
# File 'lib/alegra/payments.rb', line 59

def update(id, params)
  sanitize_params = params.deep_camel_case_lower_keys
  client.put("payments/#{id}", sanitize_params)
end