Class: CatarseCompraFacil::CompraFacil
- Inherits:
-
Object
- Object
- CatarseCompraFacil::CompraFacil
- Defined in:
- lib/catarse_compra_facil.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#city ⇒ Object
Returns the value of attribute city.
-
#email ⇒ Object
Returns the value of attribute email.
-
#entity ⇒ Object
Returns the value of attribute entity.
-
#error ⇒ Object
Returns the value of attribute error.
-
#external_reference ⇒ Object
Returns the value of attribute external_reference.
-
#info ⇒ Object
Returns the value of attribute info.
-
#insert_mode ⇒ Object
Returns the value of attribute insert_mode.
-
#name ⇒ Object
Returns the value of attribute name.
-
#nif ⇒ Object
Returns the value of attribute nif.
-
#origin ⇒ Object
Returns the value of attribute origin.
-
#password ⇒ Object
Returns the value of attribute password.
-
#payed ⇒ Object
Returns the value of attribute payed.
-
#payment_company ⇒ Object
Returns the value of attribute payment_company.
-
#phone ⇒ Object
Returns the value of attribute phone.
-
#reference ⇒ Object
Returns the value of attribute reference.
-
#server_address ⇒ Object
readonly
Returns the value of attribute server_address.
-
#state ⇒ Object
Returns the value of attribute state.
-
#user ⇒ Object
Returns the value of attribute user.
-
#user_id_back_office ⇒ Object
Returns the value of attribute user_id_back_office.
-
#user_type ⇒ Object
Returns the value of attribute user_type.
-
#value ⇒ Object
Returns the value of attribute value.
-
#zip_code ⇒ Object
Returns the value of attribute zip_code.
Instance Method Summary collapse
- #get_order_information! ⇒ Object
-
#initialize(attrs = {}) ⇒ CompraFacil
constructor
A new instance of CompraFacil.
- #send_order! ⇒ Object
Constructor Details
#initialize(attrs = {}) ⇒ CompraFacil
Returns a new instance of CompraFacil.
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/catarse_compra_facil.rb', line 31 def initialize(attrs = {}) attrs.each {|key, value| self.send("#{key}=", value)} @user_id_back_office = -1 self.payment_company = "multibanco" if Rails.env.development? || Rails.env.test? self.user_type = 10241 else self.user_type = 11249 end self.insert_mode = "SaveCompraToBDValor1" end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def address @address end |
#city ⇒ Object
Returns the value of attribute city.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def city @city end |
#email ⇒ Object
Returns the value of attribute email.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def email @email end |
#entity ⇒ Object
Returns the value of attribute entity.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def entity @entity end |
#error ⇒ Object
Returns the value of attribute error.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def error @error end |
#external_reference ⇒ Object
Returns the value of attribute external_reference.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def external_reference @external_reference end |
#info ⇒ Object
Returns the value of attribute info.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def info @info end |
#insert_mode ⇒ Object
Returns the value of attribute insert_mode.
29 30 31 |
# File 'lib/catarse_compra_facil.rb', line 29 def insert_mode @insert_mode end |
#name ⇒ Object
Returns the value of attribute name.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def name @name end |
#nif ⇒ Object
Returns the value of attribute nif.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def nif @nif end |
#origin ⇒ Object
Returns the value of attribute origin.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def origin @origin end |
#password ⇒ Object
Returns the value of attribute password.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def password @password end |
#payed ⇒ Object
Returns the value of attribute payed.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def payed @payed end |
#payment_company ⇒ Object
Returns the value of attribute payment_company.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def payment_company @payment_company end |
#phone ⇒ Object
Returns the value of attribute phone.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def phone @phone end |
#reference ⇒ Object
Returns the value of attribute reference.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def reference @reference end |
#server_address ⇒ Object (readonly)
Returns the value of attribute server_address.
29 30 31 |
# File 'lib/catarse_compra_facil.rb', line 29 def server_address @server_address end |
#state ⇒ Object
Returns the value of attribute state.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def state @state end |
#user ⇒ Object
Returns the value of attribute user.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def user @user end |
#user_id_back_office ⇒ Object
Returns the value of attribute user_id_back_office.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def user_id_back_office @user_id_back_office end |
#user_type ⇒ Object
Returns the value of attribute user_type.
29 30 31 |
# File 'lib/catarse_compra_facil.rb', line 29 def user_type @user_type end |
#value ⇒ Object
Returns the value of attribute value.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def value @value end |
#zip_code ⇒ Object
Returns the value of attribute zip_code.
8 9 10 |
# File 'lib/catarse_compra_facil.rb', line 8 def zip_code @zip_code end |
Instance Method Details
#get_order_information! ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/catarse_compra_facil.rb', line 88 def get_order_information! client = Savon.client(wsdl: self.server_address) = { "referencia" => self.reference, "IDCliente" => self.user, :password => self.password } response = client.call(:get_info_compra, message: ) if response.success? self.payed = response.to_hash[:get_info_compra_response][:pago] self.state = response.to_hash[:get_info_compra_response][:estado] end puts response.to_hash; end |
#send_order! ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/catarse_compra_facil.rb', line 71 def send_order! client = Savon.client(wsdl: self.server_address) = { :origem => self.origin, "IDCliente" => self.user, :password => self.password, :valor => self.value, :informacao => self.info, "IDUserBackoffice" => self.user_id_back_office.to_s } response = client.call(:save_compra_to_bd_valor1, message: ) if response.success? self.reference = response.to_hash[:save_compra_to_bd_valor1_response][:referencia] self.entity = response.to_hash[:save_compra_to_bd_valor1_response][:entidade] end puts response.to_hash; end |