Class: Braspag::Request::UpdateSaleRequest

Inherits:
BraspagRequest show all
Defined in:
lib/braspag/api/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.



12
13
14
15
16
17
# File 'lib/braspag/api/request/update_sale_request.rb', line 12

def initialize(type, merchant, environment)
    super(merchant)

    @environment = environment
    @type = type
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



5
6
7
# File 'lib/braspag/api/request/update_sale_request.rb', line 5

def amount
  @amount
end

#environment=(value) ⇒ Object

Sets the attribute environment

Parameters:

  • value

    the value to set the attribute environment to.



5
6
7
# File 'lib/braspag/api/request/update_sale_request.rb', line 5

def environment=(value)
  @environment = value
end

#service_tax_amountObject

Returns the value of attribute service_tax_amount.



5
6
7
# File 'lib/braspag/api/request/update_sale_request.rb', line 5

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.



5
6
7
# File 'lib/braspag/api/request/update_sale_request.rb', line 5

def type=(value)
  @type = value
end

Instance Method Details

#execute(payment_id) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/braspag/api/request/update_sale_request.rb', line 19

def execute(payment_id)
    uri = URI.parse(@environment.api + "v2/sales/" + payment_id + "/" + type)
    params = {}

    if (amount != nil)
        params["amount"] = amount
    end

    if (service_tax_amount != nil)
        params["serviceTaxAmount"] = service_tax_amount
    end

    uri.query = URI.encode_www_form(params)

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