Class: Justa::Pix

Inherits:
OrderCommom show all
Defined in:
lib/justa/resources/pix.rb

Constant Summary

Constants inherited from JustaObject

JustaObject::RESOURCES

Instance Attribute Summary

Attributes inherited from JustaObject

#attributes

Instance Method Summary collapse

Methods inherited from Model

class_name, #class_name, create, #create, #fetch, find_by_id, underscored_class_name, url, #url

Methods inherited from JustaObject

#==, #[]=, convert, #empty?, #initialize, #respond_to?, #to_hash, #to_request_params, #unsaved_attributes

Constructor Details

This class inherits a constructor from Justa::JustaObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Justa::JustaObject

Instance Method Details

#approve(**params) ⇒ Pix

Request approve to Justa api for this pix ( Only in DEVELOPMENT)

Examples:

Pay 1.0 of pix

pix_instance.approve(value: 1.0)

Parameters:

  • params (Hash)

    Parameters for function

Options Hash (**params):

  • :value (Numeric) — default: Required

    The amount that will be approved in cents format

  • :end_to_end_id (String) — default: Optional

    The reference for the payment transaction

Returns:

  • (Pix)

    Return model pix instance

Raises:



20
21
22
23
24
25
26
27
28
# File 'lib/justa/resources/pix.rb', line 20

def approve(**params)
  raise JustaError, "Can't approve value in Production environment" if Justa.production?
  raise ParamError.new("Missing value param", :value, :integer, url("approve")) unless params.has_key? :value

  Justa::Request.post(url("approve"),
                      { append_document: false,
                        params: params.merge({ client_key: @client_key }) }).call underscored_class_name
  fetch
end

#primary_keyObject

def self.url(*params)

["/#{ CGI.escape underscored_class_name }", *params].join '/'

end



7
8
9
# File 'lib/justa/resources/pix.rb', line 7

def primary_key
  tx_id
end