Class: MidasClient::Query
Constant Summary
Constants included from EndPoints
EndPoints::DEVELOPMENT, EndPoints::MANAGEMENTS, EndPoints::OPERATIONS, EndPoints::PRODUCTION, EndPoints::QUERIES, EndPoints::SUBSCRIPTIONS
Instance Attribute Summary
Attributes inherited from Request
#environment, #login, #password, #query, #subscription, #transaction
Attributes included from Util
Instance Method Summary collapse
-
#billets_summary_by_day(start_date = (Date.today.at_beginning_of_month).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d')) ⇒ Object
This method performs a query that summarizes all billet’s operations between a date period by DATE, BANK, PAYMENT_METHOD and STATUS.
-
#billets_summary_by_month(start_month = (Date.today - 1.year).strftime('%m'), start_year = ((Date.today - 1.year).strftime('%Y')), end_month = (Date.today).strftime('%m'), end_year = ((Date.today).strftime('%Y'))) ⇒ Object
This method performs a query that summarizes all billet’s operations between a date period by MONTH, BANK, PAYMENT_METHOD and STATUS.
-
#by_external_id(externalId) ⇒ Object
This method performs a query by a specific transaction’s identifier, called external ID.
-
#by_external_ids(externalIds = []) ⇒ Object
This method performs a query by an array of transaction’s identifier.
-
#by_transaction_tokens(transactionTokens = []) ⇒ Object
This method performs a query by an array of transaction’s token.
-
#cards_summary_by_day(start_date = (Date.today.at_beginning_of_month).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d')) ⇒ Object
This method performs a query that summarizes all card’s(CREDIT/DEBIT) operation between a date period by DAY, BRAND, PAYMENT_METHOD and STATUS.
-
#cards_summary_by_month(start_month = (Date.today - 1.year).strftime('%m'), start_year = ((Date.today - 1.year).strftime('%Y')), end_month = (Date.today).strftime('%m'), end_year = ((Date.today).strftime('%Y'))) ⇒ Object
This method performs a query that summarizes all card’s(CREDIT/DEBIT) operation between a date period by by MONTH, BRAND, PAYMENT_METHOD and STATUS.
-
#invoices_by_expiration_date(start_date = (Date.today - 7).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d'), status = 'PAID') ⇒ Object
This method performs a query to return all invoices for a Point Of Sale by a period (by expirationDate) and status This is a is synchronous operation, using method GET.
-
#invoices_by_payment_date(start_date = (Date.today - 7).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d'), status = 'PAID') ⇒ Object
This method performs a query to return all invoices for a Point Of Sale by a period (by paymentDate) and status This is a is synchronous operation, using method GET.
-
#list_creditcards ⇒ Object
This method performs a query to return all creditcards stored for a Point Of Sale This is a is synchronous operation, using method GET.
-
#list_customers ⇒ Object
This method performs a query to return all creditcards stored for a Point Of Sale This is a is synchronous operation, using method GET.
-
#subscriptions(status = nil) ⇒ Object
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.
-
#subscriptions_by_customer(documentType = 'CPF', documentNumber = '', status = nil) ⇒ Object
This method performs a query by a specific customer’s document type and number and return all subscriptions from = the user in the plataform.
-
#transaction_by_date(start_date = (Date.today - 7).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d'), status = nil, type = nil) ⇒ Object
This method performs a query by a range date.
-
#transactions_by_customer(documentType = 'CPF', documentNumber = '', status = nil) ⇒ Object
This method performs a query by a specific customer’s document type and number.
Methods inherited from Request
base_result, external_request, #initialize, #request
Methods included from EndPoints
#get_env, #get_environment, #production?, #set_env
Methods included from Util
#error_log, #log, #sanitize_pci, #sanitized_document_number
Constructor Details
This class inherits a constructor from MidasClient::Request
Instance Method Details
#billets_summary_by_day(start_date = (Date.today.at_beginning_of_month).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d')) ⇒ Object
This method performs a query that summarizes all billet’s operations between a date period by DATE, BANK, PAYMENT_METHOD and STATUS.
This is a is synchronous operation, using method GET
Params:
start_date: string (YYYY-MM-DD)
end_date: string (YYYY-MM-DD)
Response:
{
"result": {
"success": true,
"code": "000",
"message": "Sucesso"
},
"pagging": {
"limit": 6,
"count": 1,
"current": 1
},
"transactionsSummary": [
{
"date": "2018-01-19",
"brand": "Mastercard",
"paymentMethod": "CREDIT_CARD",
"status": "AUTHORIZED",
"count": 3,
"sum": 600,
"average": 200
},
{
"date": "2018-01-19",
"brand": "Mastercard",
"paymentMethod": "CREDIT_CARD",
"status": "CAPTURED",
"count": 3,
"sum": 300,
"average": 100
}]
}
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 |
# File 'lib/midas_client/query.rb', line 582 def billets_summary_by_day(start_date=(Date.today.at_beginning_of_month).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d')) log "Entrei em billets_summary_by_day" # 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[:billets_summary_by_day] endpoint = endpoint.gsub("{startDate}", start_date).gsub("{endDate}", end_date) # faz a chamada a plataforma de pagamento (MIDAS) response = request(method, endpoint, self.login, self.password, {}) result = response[:result] pagging = response[:pagging] if response[:transactionsSummary].kind_of?(Array) || response[:transactionsSummary].blank? transactions = response[:transactionsSummary] else transaction_array = [] transaction_array << response[:transactionsSummary] transactions = transaction_array end response[:result] = result response[:pagging] = pagging response[:transactionsSummary] = transactions response end |
#billets_summary_by_month(start_month = (Date.today - 1.year).strftime('%m'), start_year = ((Date.today - 1.year).strftime('%Y')), end_month = (Date.today).strftime('%m'), end_year = ((Date.today).strftime('%Y'))) ⇒ Object
This method performs a query that summarizes all billet’s operations between a date period by MONTH, BANK, PAYMENT_METHOD and STATUS.
This is a is synchronous operation, using method GET
Params:
start_month: string (MM)
end_month: string (MM)
start_year: string (YYYY)
end_year: string (YYYY)
Response:
{
"result": {
"success": true,
"code": "000",
"message": "Sucesso"
},
"pagging": {
"limit": 6,
"count": 1,
"current": 1
},
"transactionsSummary": [
{
"year": 2018,
"month": 1,
"brand": "Mastercard",
"paymentMethod": "CREDIT_CARD",
"status": "AUTHORIZED",
"count": 3,
"sum": 600,
"average": 200
},
{
"year": 2018,
"month": 1,
"brand": "Mastercard",
"paymentMethod": "CREDIT_CARD",
"status": "CAPTURED",
"count": 3,
"sum": 300,
"average": 200
}]
}
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 |
# File 'lib/midas_client/query.rb', line 655 def billets_summary_by_month(start_month=(Date.today - 1.year).strftime('%m'), start_year=((Date.today - 1.year).strftime('%Y')), end_month=(Date.today).strftime('%m'), end_year=((Date.today).strftime('%Y'))) log "Entrei em billets_summary_by_month" # 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[:billets_summary_by_month] endpoint = endpoint.gsub("{startMonth}", start_month).gsub("{startYear}", start_year).gsub("{endMonth}", end_month).gsub("{endYear}", end_year) # faz a chamada a plataforma de pagamento (MIDAS) response = request(method, endpoint, self.login, self.password, {}) result = response[:result] pagging = response[:pagging] if response[:transactionsSummary].kind_of?(Array) || response[:transactionsSummary].blank? transactions = response[:transactionsSummary] else transaction_array = [] transaction_array << response[:transactionsSummary] transactions = transaction_array end response[:result] = result response[:pagging] = pagging response[:transactionsSummary] = transactions response end |
#by_external_id(externalId) ⇒ Object
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"
}
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/midas_client/query.rb', line 67 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 = []) ⇒ Object
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"
}
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/midas_client/query.rb', line 92 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 = []) ⇒ Object
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"
}
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/midas_client/query.rb', line 117 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 |
#cards_summary_by_day(start_date = (Date.today.at_beginning_of_month).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d')) ⇒ Object
This method performs a query that summarizes all card’s(CREDIT/DEBIT) operation between a date period by DAY, BRAND, PAYMENT_METHOD and STATUS.
This is a is synchronous operation, using method GET
Params:
start_date: string (YYYY-MM-DD)
end_date: string (YYYY-MM-DD)
Response:
{
"result": {
"success": true,
"code": "000",
"message": "Sucesso"
},
"pagging": {
"limit": 6,
"count": 1,
"current": 1
},
"transactionsSummary": [
{
"date": "2018-01-19",
"brand": "Mastercard",
"paymentMethod": "CREDIT_CARD",
"status": "AUTHORIZED",
"count": 3,
"sum": 600,
"average": 200
},
{
"date": "2018-01-19",
"brand": "Mastercard",
"paymentMethod": "CREDIT_CARD",
"status": "CAPTURED",
"count": 3,
"sum": 300,
"average": 100
}]
}
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 |
# File 'lib/midas_client/query.rb', line 440 def cards_summary_by_day(start_date=(Date.today.at_beginning_of_month).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d')) log "Entrei em cards_summary_by_day" # 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[:cards_summary_by_day] endpoint = endpoint.gsub("{startDate}", start_date).gsub("{endDate}", end_date) # faz a chamada a plataforma de pagamento (MIDAS) response = request(method, endpoint, self.login, self.password, {}) result = response[:result] pagging = response[:pagging] if response[:transactionsSummary].kind_of?(Array) || response[:transactionsSummary].blank? transactions = response[:transactionsSummary] else transaction_array = [] transaction_array << response[:transactionsSummary] transactions = transaction_array end response[:result] = result response[:pagging] = pagging response[:transactionsSummary] = transactions response end |
#cards_summary_by_month(start_month = (Date.today - 1.year).strftime('%m'), start_year = ((Date.today - 1.year).strftime('%Y')), end_month = (Date.today).strftime('%m'), end_year = ((Date.today).strftime('%Y'))) ⇒ Object
This method performs a query that summarizes all card’s(CREDIT/DEBIT) operation between a date period by by MONTH, BRAND, PAYMENT_METHOD and STATUS.
This is a is synchronous operation, using method GET
Params:
start_month: string (MM)
end_month: string (MM)
start_year: string (YYYY)
end_year: string (YYYY)
Response:
{
"result": {
"success": true,
"code": "000",
"message": "Sucesso"
},
"pagging": {
"limit": 6,
"count": 1,
"current": 1
},
"transactionsSummary": [
{
"year": 2018,
"month": 1,
"brand": "Mastercard",
"paymentMethod": "CREDIT_CARD",
"status": "AUTHORIZED",
"count": 3,
"sum": 600,
"average": 200
},
{
"year": 2018,
"month": 1,
"brand": "Mastercard",
"paymentMethod": "CREDIT_CARD",
"status": "CAPTURED",
"count": 3,
"sum": 300,
"average": 200
}]
}
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
# File 'lib/midas_client/query.rb', line 513 def cards_summary_by_month(start_month=(Date.today - 1.year).strftime('%m'), start_year=((Date.today - 1.year).strftime('%Y')), end_month=(Date.today).strftime('%m'), end_year=((Date.today).strftime('%Y'))) log "Entrei em cards_summary_by_month" # 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[:cards_summary_by_month] endpoint = endpoint.gsub("{startMonth}", start_month).gsub("{startYear}", start_year).gsub("{endMonth}", end_month).gsub("{endYear}", end_year) # faz a chamada a plataforma de pagamento (MIDAS) response = request(method, endpoint, self.login, self.password, {}) result = response[:result] pagging = response[:pagging] if response[:transactionsSummary].kind_of?(Array) || response[:transactionsSummary].blank? transactions = response[:transactionsSummary] else transaction_array = [] transaction_array << response[:transactionsSummary] transactions = transaction_array end response[:result] = result response[:pagging] = pagging response[:transactionsSummary] = transactions response end |
#invoices_by_expiration_date(start_date = (Date.today - 7).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d'), status = 'PAID') ⇒ Object
This method performs a query to return all invoices for a Point Of Sale by a period (by expirationDate) and status
This is a is synchronous operation, using method GET
Params:
start_date: YYYY-MM-DD
end_date: YYYY-MM-DD
status: PAID/DENIED/RESERVED/CANCELLED
Response:
result: {
success: true/false
code: "XXX"
message: "Some message to you"
}
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/midas_client/query.rb', line 186 def invoices_by_expiration_date(start_date=(Date.today - 7).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d'), status = 'PAID') log "Entrei em invoices" # 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[:invoices_by_expiration_date] # monta a URL de chamada da requisição endpoint = endpoint .gsub("{startDate}", start_date).gsub("{endDate}", end_date) # monta o parâmetro status na requisição da 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[:invoices].kind_of?(Array) || response[:invoices].blank? invoices = response[:invoices] else invoice_array = [] invoice_array << response[:invoices] invoices = invoice_array end response[:result] = result response[:pagging] = pagging response[:invoices] = invoices response end |
#invoices_by_payment_date(start_date = (Date.today - 7).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d'), status = 'PAID') ⇒ Object
This method performs a query to return all invoices for a Point Of Sale by a period (by paymentDate) and status
This is a is synchronous operation, using method GET
Params:
start_date: YYYY-MM-DD
end_date: YYYY-MM-DD
status: PAID/DENIED/RESERVED/CANCELLED
Response:
result: {
success: true/false
code: "XXX"
message: "Some message to you"
}
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/midas_client/query.rb', line 234 def invoices_by_payment_date(start_date=(Date.today - 7).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d'), status = 'PAID') log "Entrei em invoices" # 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[:invoices_by_payment_date] # monta a URL de chamada da requisição endpoint = endpoint .gsub("{startDate}", start_date).gsub("{endDate}", end_date) # monta o parâmetro status na requisição da 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[:invoices].kind_of?(Array) || response[:invoices].blank? invoices = response[:invoices] else invoice_array = [] invoice_array << response[:invoices] invoices = invoice_array end response[:result] = result response[:pagging] = pagging response[:invoices] = invoices response end |
#list_creditcards ⇒ Object
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"
}
293 294 295 296 297 298 299 300 301 302 303 |
# File 'lib/midas_client/query.rb', line 293 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 ⇒ Object
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"
}
330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/midas_client/query.rb', line 330 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) ⇒ Object
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"
}
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/midas_client/query.rb', line 141 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 |
#subscriptions_by_customer(documentType = 'CPF', documentNumber = '', status = nil) ⇒ Object
This method performs a query by a specific customer’s document type and number and return all subscriptions from
the user in the plataform.
This is a is synchronous operation, using method GET
Params:
documentType: string (CPF/CNPJ)
documentNumeber: number
Response:
result: {
success: true/false
code: "XXX"
message: "Some message to you"
}
385 386 387 388 389 390 391 392 393 394 395 396 397 398 |
# File 'lib/midas_client/query.rb', line 385 def subscriptions_by_customer(documentType='CPF', documentNumber='', status = nil) log "subscriptions_by_customer" # 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_by_customer].gsub('{documentType}', documentType).gsub('{documentNumber}', sanitized_document_number(documentNumber)) # monta o parâmetro status na requisição da url endpoint = status.blank? ? endpoint.gsub("&status={status}", '') : endpoint.gsub("{status}", status) request(method, endpoint, login, password, {}) end |
#transaction_by_date(start_date = (Date.today - 7).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d'), status = nil, type = nil) ⇒ Object
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
status: string
type: string DIRECT/RECURRENT
Response:
result: {
success: true/false
code: "XXX"
message: "Some message to you"
}
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/midas_client/query.rb', line 19 def transaction_by_date(start_date=(Date.today - 7).strftime('%Y-%m-%d'), end_date = Date.today.strftime('%Y-%m-%d'), status = nil, type=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] endpoint = endpoint.gsub("{startDate}", start_date).gsub("{endDate}", end_date) # monta o parâmetro status na requisição da url endpoint = status.blank? ? endpoint.gsub("&status={status}", '') : endpoint.gsub("{status}", status) # monta o parâmetro type na requisição da url endpoint = type.blank? ? endpoint.gsub("&type={type}", '') : endpoint.gsub("{type}", type) # 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 |
#transactions_by_customer(documentType = 'CPF', documentNumber = '', status = nil) ⇒ Object
This method performs a query by a specific customer’s document type and number.
This is a is synchronous operation, using method GET
Params:
documentType: string (CPF/CNPJ)
documentNumeber: number
Response:
result: {
success: true/false
code: "XXX"
message: "Some message to you"
}
355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
# File 'lib/midas_client/query.rb', line 355 def transactions_by_customer(documentType='CPF', documentNumber='', status = nil) log "transactions_by_customer" # 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[:transactions_by_customer].gsub('{documentType}', documentType).gsub('{documentNumber}', sanitized_document_number(documentNumber)) # monta o parâmetro status na requisição da url endpoint = status.blank? ? endpoint.gsub("&status={status}", '') : endpoint.gsub("{status}", status) request(method, endpoint, login, password, {}) end |