Class: Cielo::API30::Request::UpdateSaleRequest

Inherits:
CieloRequest
  • Object
show all
Defined in:
lib/cielo/api30/request/update_sale_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, merchant, environment) ⇒ UpdateSaleRequest

Returns a new instance of UpdateSaleRequest.



14
15
16
17
18
# File 'lib/cielo/api30/request/update_sale_request.rb', line 14

def initialize(type, merchant, environment)
  super(merchant)
  @environment = environment
  @type = type
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



7
8
9
# File 'lib/cielo/api30/request/update_sale_request.rb', line 7

def amount
  @amount
end

#environment=(value) ⇒ Object

Sets the attribute environment

Parameters:

  • value

    the value to set the attribute environment to.



7
8
9
# File 'lib/cielo/api30/request/update_sale_request.rb', line 7

def environment=(value)
  @environment = value
end

#service_tax_amountObject

Returns the value of attribute service_tax_amount.



7
8
9
# File 'lib/cielo/api30/request/update_sale_request.rb', line 7

def service_tax_amount
  @service_tax_amount
end

#type=(value) ⇒ Object

Sets the attribute type

Parameters:

  • value

    the value to set the attribute type to.



7
8
9
# File 'lib/cielo/api30/request/update_sale_request.rb', line 7

def type=(value)
  @type = value
end

Instance Method Details

#execute(payment_id) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/cielo/api30/request/update_sale_request.rb', line 20

def execute(payment_id)
  uri = URI.parse([@environment.api, "1", "sales", payment_id, type].join("/"))
  params = {}

  params["amount"] = amount if amount
  params["serviceTaxAmount"] = service_tax_amount if service_tax_amount

  uri.query = URI.encode_www_form(params)

  Cielo::API30::Payment.from_json(send_request("PUT", uri))
end