class MidasClient::Query
Public Instance Methods
by_external_id(externalId)
click to toggle source
This method performs a query by a specific transaction's identifier, called external ID.¶ ↑
This is a is synchronous operation, using method GET Params: transactionToken: string (Transaction unique identification generated by customer) Response: result: { success: true/false code: "XXX" message: "Some message to you" }
# File lib/midas_client/query.rb, line 62 def by_external_id(externalId) log "Entrei em by_external_id" # define o método de envio da requisição method = :get # monta a URL de chamada da requisição endpoint = get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:by_external_id].gsub('{externalId}', externalId) request(method, endpoint, login, password, {}) end
by_external_ids(externalIds = [])
click to toggle source
This method performs a query by an array of transaction's identifier.¶ ↑
This is a is synchronous operation, using method GET Params: none Response: result: { success: true/false code: "XXX" message: "Some message to you" }
# File lib/midas_client/query.rb, line 87 def by_external_ids(externalIds = []) log "Entrei em by_external_ids" # define o método de envio da requisição method = :post # monta a URL de chamada da requisição endpoint = get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:by_external_ids] request(method, endpoint, login, password, {externalIds: externalIds}) end
by_transaction_tokens(transactionTokens = [])
click to toggle source
This method performs a query by an array of transaction's token.¶ ↑
This is a is synchronous operation, using method GET Params: none Response: result: { success: true/false code: "XXX" message: "Some message to you" }
# File lib/midas_client/query.rb, line 112 def by_transaction_tokens(transactionTokens = []) log "Entrei em by_external_ids" # define o método de envio da requisição method = :post # monta a URL de chamada da requisição endpoint = get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:by_transaction_tokens] request(method, endpoint, login, password, {transactionTokens: transactionTokens}) end
list_creditcards()
click to toggle source
This method performs a query to return all creditcards stored for a Point Of Sale¶ ↑
This is a is synchronous operation, using method GET Params: none Response: result: { success: true/false code: "XXX" message: "Some message to you" } creditCards: [ { brand: "MASTER", panLastDigits": "4832", expirationMonth": 10, expirationYear": 2019, holderName": "Nome Portador", customer: { documentType: "CPF", documentNumber: "12345678900" }, token: "b7553c62bc93ed0708b4behfcf28f3592" }
# File lib/midas_client/query.rb, line 192 def list_creditcards() log "Entrei em list_creditcards" # define o método de envio da requisição method = :get # monta a URL de chamada da requisição endpoint = get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:creditcards] # faz a chamada a plataforma de pagamento (MIDAS) request(method, endpoint, self.login, self.password, {}) end
list_customers()
click to toggle source
This method performs a query to return all creditcards stored for a Point Of Sale¶ ↑
This is a is synchronous operation, using method GET Params: none Response: result: { success: true/false code: "XXX" message: "Some message to you" } creditCards: [ { brand: "MASTER", panLastDigits": "4832", expirationMonth": 10, expirationYear": 2019, holderName": "Nome Portador", customer: { documentType: "CPF", documentNumber: "12345678900" }, token: "b7553c62bc93ed0708b4behfcf28f3592" }
# File lib/midas_client/query.rb, line 229 def list_customers() log "Entrei em list_customers" # define o método de envio da requisição method = :get # monta a URL de chamada da requisição endpoint = get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:customers] # faz a chamada a plataforma de pagamento (MIDAS) request(method, endpoint, self.login, self.password, {}) end
subscriptions(status = nil)
click to toggle source
This method performs a query to return all subscriptions for a Point Of Sale by status¶ ↑
This is a is synchronous operation, using method GET Params: status: ACTIVE/CANCELLED Response: result: { success: true/false code: "XXX" message: "Some message to you" }
# File lib/midas_client/query.rb, line 136 def subscriptions(status = nil) log "Entrei em subscriptions" # define o método de envio da requisição method = :get # monta a URL de chamada da requisição endpoint = get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:subscriptions] # monta os parâmetros da requisição na url endpoint = status.blank? ? endpoint.gsub("status={status}", '') : endpoint.gsub("{status}", status) # faz a chamada a plataforma de pagamento (MIDAS) response = request(method, endpoint, self.login, self.password, {}) result = response[:result] pagging = response[:pagging] if response[:subscriptions].kind_of?(Array) || response[:subscriptions].blank? subscriptions = response[:subscriptions] else subscription_array = [] subscription_array << response[:subscriptions] subscriptions = subscription_array end response[:result] = result response[:pagging] = pagging response[:subscriptions] = subscriptions response end
transaction_by_date(start_date=(Date.today - 7).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d'), status = nil)
click to toggle source
This method performs a query by a range date.¶ ↑
This is a is synchronous operation, using method GET Params: start_date: date format YYYY-MM-DD send_date: date format YYYY-MM-DD Response: result: { success: true/false code: "XXX" message: "Some message to you" }
# File lib/midas_client/query.rb, line 18 def transaction_by_date(start_date=(Date.today - 7).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d'), status = nil) log "Entrei em transaction_by_date" # define o método de envio da requisição method = :get # monta a URL de chamada da requisição endpoint = get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:by_period].gsub("{startDate}", start_date).gsub("{endDate}", end_date) # monta os parâmetros da requisição na url endpoint = status.blank? ? endpoint.gsub("{status}", '') : endpoint.gsub("{status}", status) # faz a chamada a plataforma de pagamento (MIDAS) response = request(method, endpoint, self.login, self.password, {}) result = response[:result] pagging = response[:pagging] if response[:transactions].kind_of?(Array) || response[:transactions].blank? transactions = response[:transactions] else transaction_array = [] transaction_array << response[:transactions] transactions = transaction_array end response[:result] = result response[:pagging] = pagging response[:transactions] = transactions response end