Class: Braspag::Request::CreateSaleRequest

Inherits:
BraspagRequest show all
Defined in:
lib/braspag/api/request/create_sale_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(merchant, environment) ⇒ CreateSaleRequest

Returns a new instance of CreateSaleRequest.



8
9
10
11
12
# File 'lib/braspag/api/request/create_sale_request.rb', line 8

def initialize(merchant, environment)
    super(merchant)

    @environment = environment
end

Instance Attribute Details

#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/create_sale_request.rb', line 5

def environment=(value)
  @environment = value
end

Instance Method Details

#execute(sale) ⇒ Object



14
15
16
17
18
# File 'lib/braspag/api/request/create_sale_request.rb', line 14

def execute(sale)
    uri = URI.parse(@environment.api + "v2/sales")

    Braspag::Sale.from_json(send_request("POST", uri, sale))
end