Class: FORCAST::Qvo::Pago
- Inherits:
-
Object
- Object
- FORCAST::Qvo::Pago
- Defined in:
- lib/forcast/utils/qvo.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#json_send ⇒ Object
Returns the value of attribute json_send.
-
#metodo ⇒ Object
Returns the value of attribute metodo.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#allTransactions ⇒ Object
Todas las transacciones realizadas.
-
#allUsers ⇒ Object
Mostrar usuarios.
-
#cardInscription(userId, return_url) ⇒ Object
Inscribir/Ingresar tarjeta.
-
#cardsUser(userId) ⇒ Object
Mostrar Tarjetas de los usuarios.
-
#cobroUser(userId, cardId, amount, description) ⇒ Object
Cobrar a la tarjeta de un usuario.
- #constructor ⇒ Object
-
#createUser(email, nombre, address, phone) ⇒ Object
Crear usuarios.
-
#deleteCard(userId, cardId) ⇒ Object
Eliminar tarjeta.
-
#deleteUser(userId) ⇒ Object
Eliminar usuario.
-
#initialize ⇒ Pago
constructor
A new instance of Pago.
- #oneUser(userId) ⇒ Object
- #parser(varible, key1 = '') ⇒ Object
-
#refundCard(transactionId) ⇒ Object
Reembolso de pago efectuado(transaccion).
-
#updateUser(userId, variable, dato) ⇒ Object
Update usuario.
- #valid_json?(json) ⇒ Boolean
Constructor Details
#initialize ⇒ Pago
Returns a new instance of Pago.
9 10 11 |
# File 'lib/forcast/utils/qvo.rb', line 9 def initialize self.headers = {} end |
Instance Attribute Details
#headers ⇒ Object
Returns the value of attribute headers.
4 5 6 |
# File 'lib/forcast/utils/qvo.rb', line 4 def headers @headers end |
#json_send ⇒ Object
Returns the value of attribute json_send.
6 7 8 |
# File 'lib/forcast/utils/qvo.rb', line 6 def json_send @json_send end |
#metodo ⇒ Object
Returns the value of attribute metodo.
7 8 9 |
# File 'lib/forcast/utils/qvo.rb', line 7 def metodo @metodo end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/forcast/utils/qvo.rb', line 5 def url @url end |
Instance Method Details
#allTransactions ⇒ Object
Todas las transacciones realizadas
91 92 93 94 |
# File 'lib/forcast/utils/qvo.rb', line 91 def allTransactions() user = parser(servidor.conexion(:get, {},'/transactions')[1], "customer") puts user[0]#ultimo usuario end |
#allUsers ⇒ Object
Mostrar usuarios
14 15 16 17 18 19 20 21 22 |
# File 'lib/forcast/utils/qvo.rb', line 14 def allUsers() json_recived = constructor do self.metodo = :get self.url = "/customers" self.json_send = {} end #userId = parser(servidor.conexion(:get, {},'/customers')[1], "id") #puts userId[0].to_s #Ultimo usuario creado end |
#cardInscription(userId, return_url) ⇒ Object
Inscribir/Ingresar tarjeta
78 79 80 81 82 |
# File 'lib/forcast/utils/qvo.rb', line 78 def cardInscription(userId, return_url) ruta = '/customers/'+userId+'/cards/inscriptions' #return_url redirije al usuario post inscripcion de tarjeta puts parser(servidor.conexion(:post, {},ruta,{return_url: return_url})[1]) end |
#cardsUser(userId) ⇒ Object
Mostrar Tarjetas de los usuarios
60 61 62 63 64 65 66 |
# File 'lib/forcast/utils/qvo.rb', line 60 def cardsUser(userId) json_recived = constructor do self.metodo = :get self.url = "/customers/"+userId+"/cards" self.json_send = {} end end |
#cobroUser(userId, cardId, amount, description) ⇒ Object
Cobrar a la tarjeta de un usuario
69 70 71 72 73 74 75 |
# File 'lib/forcast/utils/qvo.rb', line 69 def cobroUser(userId, cardId, amount, description) json_recived = constructor do self.metodo = :post self.url = "/customers/"+userId+"/cards/"+cardId+"/charge" self.json_send = {amount: amount, description: description} end end |
#constructor ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/forcast/utils/qvo.rb', line 102 def constructor yield resp = SERVIDORPAGOS.conexion(self.metodo, self.headers, self.url, self.json_send) return true if resp[1].blank? json_recived = {} puts resp if resp[0] && self.valid_json?(resp[1]) json_recived = JSON.parse(resp[1]) unless json_recived.is_a?(Array) unless json_recived["error"].nil? logger.info "[QVO] "+json_recived["error"].to_s return false end end return json_recived else return false end end |
#createUser(email, nombre, address, phone) ⇒ Object
Crear usuarios
34 35 36 37 38 39 40 |
# File 'lib/forcast/utils/qvo.rb', line 34 def createUser(email, nombre, address, phone) json_recived = constructor do self.metodo = :post self.url = "/customers" self.json_send = {email: email, name: nombre, address: address, phone: phone} end end |
#deleteCard(userId, cardId) ⇒ Object
Eliminar tarjeta
85 86 87 88 |
# File 'lib/forcast/utils/qvo.rb', line 85 def deleteCard(userId, cardId) ruta = "/customers/"+userId+"/cards/"+cardId puts parser(servidor.conexion(:delete, {},ruta)[1]) end |
#deleteUser(userId) ⇒ Object
Eliminar usuario
52 53 54 55 56 57 58 |
# File 'lib/forcast/utils/qvo.rb', line 52 def deleteUser(userId) json_recived = constructor do self.metodo = :delete self.url = "/customers/"+userId self.json_send = {} end end |
#oneUser(userId) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/forcast/utils/qvo.rb', line 24 def oneUser(userId) json_recived = constructor do self.metodo = :get self.url = "/customers/"+userId self.json_send = {} end #userId = parser(servidor.conexion(:get, {},'/customers')[1], "id") #puts userId[0].to_s #Ultimo usuario creado end |
#parser(varible, key1 = '') ⇒ Object
132 133 134 135 136 137 138 |
# File 'lib/forcast/utils/qvo.rb', line 132 def parser(varible, key1 = '') if key1 == '' return JSON.pretty_generate(FORCAST::Server.response_to_json(varible)) else return FORCAST::Server.response_to_json(varible).map {|i| i[key1]} end end |
#refundCard(transactionId) ⇒ Object
Reembolso de pago efectuado(transaccion)
97 98 99 100 |
# File 'lib/forcast/utils/qvo.rb', line 97 def refundCard(transactionId) ruta = "/transactions/"+transactionId+"/refund" puts parser(servidor.conexion(:post, {},ruta)[1]) end |
#updateUser(userId, variable, dato) ⇒ Object
Update usuario
43 44 45 46 47 48 49 |
# File 'lib/forcast/utils/qvo.rb', line 43 def updateUser(userId,variable,dato) json_recived = constructor do self.metodo = :put self.url = "/customers/"+userId self.json_send = {"#{variable}" => dato} end end |
#valid_json?(json) ⇒ Boolean
122 123 124 125 126 127 128 129 130 |
# File 'lib/forcast/utils/qvo.rb', line 122 def valid_json?(json) begin JSON.parse(json) return true rescue JSON::ParserError => e puts e return false end end |