midas_client 0.2.4 → 0.2.13b
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +59 -0
- data/lib/midas_client/endpoints.rb +27 -7
- data/lib/midas_client/management.rb +44 -11
- data/lib/midas_client/query.rb +656 -215
- data/lib/midas_client/request.rb +2 -2
- data/lib/midas_client/subscription.rb +174 -8
- data/lib/midas_client/transaction.rb +72 -0
- data/lib/midas_client/util.rb +4 -0
- data/lib/midas_client/version.rb +1 -1
- data/lib/midas_client.rb +2 -2
- metadata +5 -7
- data/lib/midas_client/billet.rb +0 -7
    
        data/lib/midas_client/query.rb
    CHANGED
    
    | @@ -1,243 +1,684 @@ | |
| 1 1 | 
             
            module MidasClient
         | 
| 2 | 
            -
             | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
             | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 18 | 
            -
             | 
| 19 | 
            -
             | 
| 2 | 
            +
              class Query < Request
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                  #= This method performs a query by a range date.
         | 
| 5 | 
            +
                  # This is a is synchronous operation, using method GET
         | 
| 6 | 
            +
                  #
         | 
| 7 | 
            +
                  # Params:
         | 
| 8 | 
            +
                  #   start_date: date format YYYY-MM-DD
         | 
| 9 | 
            +
                  #   send_date: date format YYYY-MM-DD
         | 
| 10 | 
            +
                  #   status: string
         | 
| 11 | 
            +
                  #   type: string DIRECT/RECURRENT
         | 
| 12 | 
            +
                  #
         | 
| 13 | 
            +
                  # Response:
         | 
| 14 | 
            +
                  #   result: {
         | 
| 15 | 
            +
                  #     success: true/false
         | 
| 16 | 
            +
                  #     code: "XXX"
         | 
| 17 | 
            +
                  #     message: "Some message to you"
         | 
| 18 | 
            +
                  #   }
         | 
| 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)
         | 
| 20 | 
            +
                      log "Entrei em transaction_by_date"
         | 
| 21 | 
            +
                      # define o método de envio da requisição
         | 
| 22 | 
            +
                      method = :get
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                      # monta a URL de chamada da requisição
         | 
| 25 | 
            +
                      endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:by_period]
         | 
| 26 | 
            +
                      endpoint =  endpoint.gsub("{startDate}", start_date).gsub("{endDate}", end_date)
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                      # monta o parâmetro status na requisição da url
         | 
| 29 | 
            +
                      endpoint = status.blank? ? endpoint.gsub("&status={status}", '') : endpoint.gsub("{status}", status)
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                      # monta o parâmetro type na requisição da url
         | 
| 32 | 
            +
                      endpoint = type.blank? ? endpoint.gsub("&type={type}", '') : endpoint.gsub("{type}", type)
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                      # faz a chamada a plataforma de pagamento (MIDAS)
         | 
| 35 | 
            +
                      response = request(method, endpoint, self.login, self.password, {})
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                      result = response[:result]
         | 
| 38 | 
            +
                      pagging = response[:pagging]
         | 
| 39 | 
            +
                      if response[:transactions].kind_of?(Array) || response[:transactions].blank?
         | 
| 40 | 
            +
                        transactions = response[:transactions]
         | 
| 41 | 
            +
                      else
         | 
| 42 | 
            +
                        transaction_array = []
         | 
| 43 | 
            +
                        transaction_array << response[:transactions]
         | 
| 44 | 
            +
                        transactions = transaction_array
         | 
| 45 | 
            +
                      end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                      response[:result] = result
         | 
| 48 | 
            +
                      response[:pagging] = pagging
         | 
| 49 | 
            +
                      response[:transactions] = transactions
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                      response
         | 
| 52 | 
            +
                  end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                  #= This method performs a query by a specific transaction's identifier, called external ID.
         | 
| 55 | 
            +
                  # This is a is synchronous operation, using method GET
         | 
| 56 | 
            +
                  #
         | 
| 57 | 
            +
                  # Params:
         | 
| 58 | 
            +
                  #   transactionToken: string (Transaction unique identification generated by customer)
         | 
| 59 | 
            +
                  #
         | 
| 60 | 
            +
                  #
         | 
| 61 | 
            +
                  # Response:
         | 
| 62 | 
            +
                  #   result: {
         | 
| 63 | 
            +
                  #     success: true/false
         | 
| 64 | 
            +
                  #     code: "XXX"
         | 
| 65 | 
            +
                  #     message: "Some message to you"
         | 
| 66 | 
            +
                  #   }
         | 
| 67 | 
            +
                  def by_external_id(externalId)
         | 
| 68 | 
            +
                    log "Entrei em by_external_id"
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                    # define o método de envio da requisição
         | 
| 71 | 
            +
                    method = :get
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                    # monta a URL de chamada da requisição
         | 
| 74 | 
            +
                    endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:by_external_id].gsub('{externalId}', externalId)
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                    request(method, endpoint, login, password, {})
         | 
| 77 | 
            +
                  end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                  #= This method performs a query by an array of transaction's identifier.
         | 
| 80 | 
            +
                  # This is a is synchronous operation, using method GET
         | 
| 81 | 
            +
                  #
         | 
| 82 | 
            +
                  # Params:
         | 
| 83 | 
            +
                  #   none
         | 
| 84 | 
            +
                  #
         | 
| 85 | 
            +
                  #
         | 
| 86 | 
            +
                  # Response:
         | 
| 87 | 
            +
                  #   result: {
         | 
| 88 | 
            +
                  #     success: true/false
         | 
| 89 | 
            +
                  #     code: "XXX"
         | 
| 90 | 
            +
                  #     message: "Some message to you"
         | 
| 91 | 
            +
                  #   }
         | 
| 92 | 
            +
                  def by_external_ids(externalIds = [])
         | 
| 93 | 
            +
                    log "Entrei em by_external_ids"
         | 
| 94 | 
            +
             | 
| 95 | 
            +
                    # define o método de envio da requisição
         | 
| 96 | 
            +
                    method = :post
         | 
| 97 | 
            +
             | 
| 98 | 
            +
                    # monta a URL de chamada da requisição
         | 
| 99 | 
            +
                    endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:by_external_ids]
         | 
| 100 | 
            +
             | 
| 101 | 
            +
                    request(method, endpoint, login, password, {externalIds: externalIds})
         | 
| 102 | 
            +
                  end
         | 
| 103 | 
            +
             | 
| 104 | 
            +
                  #= This method performs a query by an array of transaction's token.
         | 
| 105 | 
            +
                  # This is a is synchronous operation, using method GET
         | 
| 106 | 
            +
                  #
         | 
| 107 | 
            +
                  # Params:
         | 
| 108 | 
            +
                  #   none
         | 
| 109 | 
            +
                  #
         | 
| 110 | 
            +
                  #
         | 
| 111 | 
            +
                  # Response:
         | 
| 112 | 
            +
                  #   result: {
         | 
| 113 | 
            +
                  #     success: true/false
         | 
| 114 | 
            +
                  #     code: "XXX"
         | 
| 115 | 
            +
                  #     message: "Some message to you"
         | 
| 116 | 
            +
                  #   }
         | 
| 117 | 
            +
                  def by_transaction_tokens(transactionTokens = [])
         | 
| 118 | 
            +
                    log "Entrei em by_external_ids"
         | 
| 119 | 
            +
             | 
| 120 | 
            +
                    # define o método de envio da requisição
         | 
| 121 | 
            +
                    method = :post
         | 
| 122 | 
            +
             | 
| 123 | 
            +
                    # monta a URL de chamada da requisição
         | 
| 124 | 
            +
                    endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:by_transaction_tokens]
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                    request(method, endpoint, login, password, {transactionTokens: transactionTokens})
         | 
| 127 | 
            +
                  end
         | 
| 128 | 
            +
             | 
| 129 | 
            +
                  #= This method performs a query to return all subscriptions for a Point Of Sale by status
         | 
| 130 | 
            +
                  # This is a is synchronous operation, using method GET
         | 
| 131 | 
            +
                  #
         | 
| 132 | 
            +
                  # Params:
         | 
| 133 | 
            +
                  #   status: ACTIVE/CANCELLED
         | 
| 134 | 
            +
                  #
         | 
| 135 | 
            +
                  # Response:
         | 
| 136 | 
            +
                  #   result: {
         | 
| 137 | 
            +
                  #     success: true/false
         | 
| 138 | 
            +
                  #     code: "XXX"
         | 
| 139 | 
            +
                  #     message: "Some message to you"
         | 
| 140 | 
            +
                  #   }
         | 
| 141 | 
            +
                  def subscriptions(status = nil)
         | 
| 142 | 
            +
                    log "Entrei em subscriptions"
         | 
| 20 143 | 
             
                    # define o método de envio da requisição
         | 
| 21 144 | 
             
                    method = :get
         | 
| 22 145 |  | 
| 23 146 | 
             
                    # monta a URL de chamada da requisição
         | 
| 24 | 
            -
                    endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[: | 
| 147 | 
            +
                    endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:subscriptions]
         | 
| 25 148 |  | 
| 26 149 | 
             
                    # monta os parâmetros da requisição na url
         | 
| 27 | 
            -
                    endpoint = status.blank? ? endpoint.gsub("{status}", '') : endpoint.gsub("{status}", status)
         | 
| 150 | 
            +
                    endpoint = status.blank? ? endpoint.gsub("?status={status}", '') : endpoint.gsub("{status}", status)
         | 
| 151 | 
            +
             | 
| 152 | 
            +
                    # faz a chamada a plataforma de pagamento (MIDAS)
         | 
| 153 | 
            +
                    response = request(method, endpoint, self.login, self.password, {})
         | 
| 154 | 
            +
             | 
| 155 | 
            +
                    result = response[:result]
         | 
| 156 | 
            +
                    pagging = response[:pagging]
         | 
| 157 | 
            +
                    if response[:subscriptions].kind_of?(Array) || response[:subscriptions].blank?
         | 
| 158 | 
            +
                      subscriptions = response[:subscriptions]
         | 
| 159 | 
            +
                    else
         | 
| 160 | 
            +
                      subscription_array = []
         | 
| 161 | 
            +
                      subscription_array << response[:subscriptions]
         | 
| 162 | 
            +
                      subscriptions = subscription_array
         | 
| 163 | 
            +
                    end
         | 
| 164 | 
            +
             | 
| 165 | 
            +
                    response[:result] = result
         | 
| 166 | 
            +
                    response[:pagging] = pagging
         | 
| 167 | 
            +
                    response[:subscriptions] = subscriptions
         | 
| 168 | 
            +
             | 
| 169 | 
            +
                    response
         | 
| 170 | 
            +
                  end
         | 
| 171 | 
            +
             | 
| 172 | 
            +
                  #= This method performs a query to return all invoices for a Point Of Sale by a period (by expirationDate) and status
         | 
| 173 | 
            +
                  # This is a is synchronous operation, using method GET
         | 
| 174 | 
            +
                  #
         | 
| 175 | 
            +
                  # Params:
         | 
| 176 | 
            +
                  #   start_date: YYYY-MM-DD
         | 
| 177 | 
            +
                  #   end_date: YYYY-MM-DD
         | 
| 178 | 
            +
                  #   status: PAID/DENIED/RESERVED/CANCELLED
         | 
| 179 | 
            +
                  #
         | 
| 180 | 
            +
                  # Response:
         | 
| 181 | 
            +
                  #   result: {
         | 
| 182 | 
            +
                  #     success: true/false
         | 
| 183 | 
            +
                  #     code: "XXX"
         | 
| 184 | 
            +
                  #     message: "Some message to you"
         | 
| 185 | 
            +
                  #   }
         | 
| 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')
         | 
| 187 | 
            +
                    log "Entrei em invoices"
         | 
| 188 | 
            +
                    # define o método de envio da requisição
         | 
| 189 | 
            +
                    method = :get
         | 
| 190 | 
            +
             | 
| 191 | 
            +
                    # monta a URL de chamada da requisição
         | 
| 192 | 
            +
                    endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:invoices_by_expiration_date]
         | 
| 193 | 
            +
             | 
| 194 | 
            +
                    # monta a URL de chamada da requisição
         | 
| 195 | 
            +
                    endpoint =  endpoint .gsub("{startDate}", start_date).gsub("{endDate}", end_date)
         | 
| 196 | 
            +
             | 
| 197 | 
            +
                    # monta o parâmetro status na requisição da url
         | 
| 198 | 
            +
                    endpoint = status.blank? ? endpoint.gsub("&status={status}", '') : endpoint.gsub("{status}", status)
         | 
| 28 199 |  | 
| 29 200 | 
             
                    # faz a chamada a plataforma de pagamento (MIDAS)
         | 
| 30 201 | 
             
                    response = request(method, endpoint, self.login, self.password, {})
         | 
| 31 202 |  | 
| 32 203 | 
             
                    result = response[:result]
         | 
| 33 204 | 
             
                    pagging = response[:pagging]
         | 
| 34 | 
            -
                    if response[: | 
| 35 | 
            -
                       | 
| 205 | 
            +
                    if response[:invoices].kind_of?(Array) || response[:invoices].blank?
         | 
| 206 | 
            +
                      invoices = response[:invoices]
         | 
| 207 | 
            +
                    else
         | 
| 208 | 
            +
                      invoice_array = []
         | 
| 209 | 
            +
                      invoice_array << response[:invoices]
         | 
| 210 | 
            +
                      invoices = invoice_array
         | 
| 211 | 
            +
                    end
         | 
| 212 | 
            +
             | 
| 213 | 
            +
                    response[:result] = result
         | 
| 214 | 
            +
                    response[:pagging] = pagging
         | 
| 215 | 
            +
                    response[:invoices] = invoices
         | 
| 216 | 
            +
             | 
| 217 | 
            +
                    response
         | 
| 218 | 
            +
                  end
         | 
| 219 | 
            +
             | 
| 220 | 
            +
                  #= This method performs a query to return all invoices for a Point Of Sale by a period (by paymentDate) and status
         | 
| 221 | 
            +
                  # This is a is synchronous operation, using method GET
         | 
| 222 | 
            +
                  #
         | 
| 223 | 
            +
                  # Params:
         | 
| 224 | 
            +
                  #   start_date: YYYY-MM-DD
         | 
| 225 | 
            +
                  #   end_date: YYYY-MM-DD
         | 
| 226 | 
            +
                  #   status: PAID/DENIED/RESERVED/CANCELLED
         | 
| 227 | 
            +
                  #
         | 
| 228 | 
            +
                  # Response:
         | 
| 229 | 
            +
                  #   result: {
         | 
| 230 | 
            +
                  #     success: true/false
         | 
| 231 | 
            +
                  #     code: "XXX"
         | 
| 232 | 
            +
                  #     message: "Some message to you"
         | 
| 233 | 
            +
                  #   }
         | 
| 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')
         | 
| 235 | 
            +
                    log "Entrei em invoices"
         | 
| 236 | 
            +
                    # define o método de envio da requisição
         | 
| 237 | 
            +
                    method = :get
         | 
| 238 | 
            +
             | 
| 239 | 
            +
                    # monta a URL de chamada da requisição
         | 
| 240 | 
            +
                    endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:invoices_by_payment_date]
         | 
| 241 | 
            +
             | 
| 242 | 
            +
                    # monta a URL de chamada da requisição
         | 
| 243 | 
            +
                    endpoint =  endpoint .gsub("{startDate}", start_date).gsub("{endDate}", end_date)
         | 
| 244 | 
            +
             | 
| 245 | 
            +
                    # monta o parâmetro status na requisição da url
         | 
| 246 | 
            +
                    endpoint = status.blank? ? endpoint.gsub("&status={status}", '') : endpoint.gsub("{status}", status)
         | 
| 247 | 
            +
             | 
| 248 | 
            +
                    # faz a chamada a plataforma de pagamento (MIDAS)
         | 
| 249 | 
            +
                    response = request(method, endpoint, self.login, self.password, {})
         | 
| 250 | 
            +
             | 
| 251 | 
            +
                    result = response[:result]
         | 
| 252 | 
            +
                    pagging = response[:pagging]
         | 
| 253 | 
            +
                    if response[:invoices].kind_of?(Array) || response[:invoices].blank?
         | 
| 254 | 
            +
                      invoices = response[:invoices]
         | 
| 255 | 
            +
                    else
         | 
| 256 | 
            +
                      invoice_array = []
         | 
| 257 | 
            +
                      invoice_array << response[:invoices]
         | 
| 258 | 
            +
                      invoices = invoice_array
         | 
| 259 | 
            +
                    end
         | 
| 260 | 
            +
             | 
| 261 | 
            +
                    response[:result] = result
         | 
| 262 | 
            +
                    response[:pagging] = pagging
         | 
| 263 | 
            +
                    response[:invoices] = invoices
         | 
| 264 | 
            +
             | 
| 265 | 
            +
                    response
         | 
| 266 | 
            +
                  end
         | 
| 267 | 
            +
             | 
| 268 | 
            +
                  #= This method performs a query to return all creditcards stored for a Point Of Sale
         | 
| 269 | 
            +
                  # This is a is synchronous operation, using method GET
         | 
| 270 | 
            +
                  #
         | 
| 271 | 
            +
                  # Params:
         | 
| 272 | 
            +
                  #   none
         | 
| 273 | 
            +
                  #
         | 
| 274 | 
            +
                  # Response:
         | 
| 275 | 
            +
                  #   result: {
         | 
| 276 | 
            +
                  #     success: true/false
         | 
| 277 | 
            +
                  #     code: "XXX"
         | 
| 278 | 
            +
                  #     message: "Some message to you"
         | 
| 279 | 
            +
                  #   }
         | 
| 280 | 
            +
                  #   creditCards: [
         | 
| 281 | 
            +
                  #   {
         | 
| 282 | 
            +
                  #      brand: "MASTER",
         | 
| 283 | 
            +
                  #      panLastDigits": "4832",
         | 
| 284 | 
            +
                  #      expirationMonth": 10,
         | 
| 285 | 
            +
                  #      expirationYear": 2019,
         | 
| 286 | 
            +
                  #      holderName": "Nome Portador",
         | 
| 287 | 
            +
                  #      customer: {
         | 
| 288 | 
            +
                  #         documentType: "CPF",
         | 
| 289 | 
            +
                  #         documentNumber: "12345678900"
         | 
| 290 | 
            +
                  #      },
         | 
| 291 | 
            +
                  #      token: "b7553c62bc93ed0708b4behfcf28f3592"
         | 
| 292 | 
            +
                  #    }
         | 
| 293 | 
            +
                  def list_creditcards()
         | 
| 294 | 
            +
                    log "Entrei em list_creditcards"
         | 
| 295 | 
            +
                    # define o método de envio da requisição
         | 
| 296 | 
            +
                    method = :get
         | 
| 297 | 
            +
             | 
| 298 | 
            +
                    # monta a URL de chamada da requisição
         | 
| 299 | 
            +
                    endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:creditcards]
         | 
| 300 | 
            +
             | 
| 301 | 
            +
                    # faz a chamada a plataforma de pagamento (MIDAS)
         | 
| 302 | 
            +
                    request(method, endpoint, self.login, self.password, {})
         | 
| 303 | 
            +
                  end
         | 
| 304 | 
            +
             | 
| 305 | 
            +
                  #= This method performs a query to return all creditcards stored for a Point Of Sale
         | 
| 306 | 
            +
                  # This is a is synchronous operation, using method GET
         | 
| 307 | 
            +
                  #
         | 
| 308 | 
            +
                  # Params:
         | 
| 309 | 
            +
                  #   none
         | 
| 310 | 
            +
                  #
         | 
| 311 | 
            +
                  # Response:
         | 
| 312 | 
            +
                  #   result: {
         | 
| 313 | 
            +
                  #     success: true/false
         | 
| 314 | 
            +
                  #     code: "XXX"
         | 
| 315 | 
            +
                  #     message: "Some message to you"
         | 
| 316 | 
            +
                  #   }
         | 
| 317 | 
            +
                  #   creditCards: [
         | 
| 318 | 
            +
                  #   {
         | 
| 319 | 
            +
                  #      brand: "MASTER",
         | 
| 320 | 
            +
                  #      panLastDigits": "4832",
         | 
| 321 | 
            +
                  #      expirationMonth": 10,
         | 
| 322 | 
            +
                  #      expirationYear": 2019,
         | 
| 323 | 
            +
                  #      holderName": "Nome Portador",
         | 
| 324 | 
            +
                  #      customer: {
         | 
| 325 | 
            +
                  #         documentType: "CPF",
         | 
| 326 | 
            +
                  #         documentNumber: "12345678900"
         | 
| 327 | 
            +
                  #      },
         | 
| 328 | 
            +
                  #      token: "b7553c62bc93ed0708b4behfcf28f3592"
         | 
| 329 | 
            +
                  #    }
         | 
| 330 | 
            +
                  def list_customers()
         | 
| 331 | 
            +
                    log "Entrei em list_customers"
         | 
| 332 | 
            +
                    # define o método de envio da requisição
         | 
| 333 | 
            +
                    method = :get
         | 
| 334 | 
            +
             | 
| 335 | 
            +
                    # monta a URL de chamada da requisição
         | 
| 336 | 
            +
                    endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:customers]
         | 
| 337 | 
            +
             | 
| 338 | 
            +
                    # faz a chamada a plataforma de pagamento (MIDAS)
         | 
| 339 | 
            +
                    request(method, endpoint, self.login, self.password, {})
         | 
| 340 | 
            +
                  end
         | 
| 341 | 
            +
             | 
| 342 | 
            +
                  #= This method performs a query by a specific customer's document type and number.
         | 
| 343 | 
            +
                  # This is a is synchronous operation, using method GET
         | 
| 344 | 
            +
                  #
         | 
| 345 | 
            +
                  # Params:
         | 
| 346 | 
            +
                  #   documentType: string (CPF/CNPJ)
         | 
| 347 | 
            +
                  #   documentNumeber: number
         | 
| 348 | 
            +
                  #
         | 
| 349 | 
            +
                  # Response:
         | 
| 350 | 
            +
                  #   result: {
         | 
| 351 | 
            +
                  #     success: true/false
         | 
| 352 | 
            +
                  #     code: "XXX"
         | 
| 353 | 
            +
                  #     message: "Some message to you"
         | 
| 354 | 
            +
                  #   }
         | 
| 355 | 
            +
                  def transactions_by_customer(documentType='CPF', documentNumber='', status = nil)
         | 
| 356 | 
            +
                    log "transactions_by_customer"
         | 
| 357 | 
            +
             | 
| 358 | 
            +
                    # define o método de envio da requisição
         | 
| 359 | 
            +
                    method = :get
         | 
| 360 | 
            +
             | 
| 361 | 
            +
                    # monta a URL de chamada da requisição
         | 
| 362 | 
            +
                    endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:transactions_by_customer].gsub('{documentType}', documentType).gsub('{documentNumber}', sanitized_document_number(documentNumber))
         | 
| 363 | 
            +
             | 
| 364 | 
            +
                    # monta o parâmetro status na requisição da url
         | 
| 365 | 
            +
                    endpoint = status.blank? ? endpoint.gsub("&status={status}", '') : endpoint.gsub("{status}", status)
         | 
| 366 | 
            +
             | 
| 367 | 
            +
                    request(method, endpoint, login, password, {})
         | 
| 368 | 
            +
                  end
         | 
| 369 | 
            +
             | 
| 370 | 
            +
                  #= This method performs a query by a specific customer's document type and number and return all subscriptions from
         | 
| 371 | 
            +
                  #= the user in the plataform.
         | 
| 372 | 
            +
                  #
         | 
| 373 | 
            +
                  # This is a is synchronous operation, using method GET
         | 
| 374 | 
            +
                  #
         | 
| 375 | 
            +
                  # Params:
         | 
| 376 | 
            +
                  #   documentType: string (CPF/CNPJ)
         | 
| 377 | 
            +
                  #   documentNumeber: number
         | 
| 378 | 
            +
                  #
         | 
| 379 | 
            +
                  # Response:
         | 
| 380 | 
            +
                  #   result: {
         | 
| 381 | 
            +
                  #     success: true/false
         | 
| 382 | 
            +
                  #     code: "XXX"
         | 
| 383 | 
            +
                  #     message: "Some message to you"
         | 
| 384 | 
            +
                  #   }
         | 
| 385 | 
            +
                  def subscriptions_by_customer(documentType='CPF', documentNumber='', status = nil)
         | 
| 386 | 
            +
                    log "subscriptions_by_customer"
         | 
| 387 | 
            +
             | 
| 388 | 
            +
                    # define o método de envio da requisição
         | 
| 389 | 
            +
                    method = :get
         | 
| 390 | 
            +
             | 
| 391 | 
            +
                    # monta a URL de chamada da requisição
         | 
| 392 | 
            +
                    endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:subscriptions_by_customer].gsub('{documentType}', documentType).gsub('{documentNumber}', sanitized_document_number(documentNumber))
         | 
| 393 | 
            +
             | 
| 394 | 
            +
                    # monta o parâmetro status na requisição da url
         | 
| 395 | 
            +
                    endpoint = status.blank? ? endpoint.gsub("&status={status}", '') : endpoint.gsub("{status}", status)
         | 
| 396 | 
            +
             | 
| 397 | 
            +
                    request(method, endpoint, login, password, {})
         | 
| 398 | 
            +
                  end
         | 
| 399 | 
            +
             | 
| 400 | 
            +
                  #= This method performs a query that summarizes all card's(CREDIT/DEBIT) operation between a date period by DAY, BRAND, PAYMENT_METHOD and STATUS.
         | 
| 401 | 
            +
                  #
         | 
| 402 | 
            +
                  # This is a is synchronous operation, using method GET
         | 
| 403 | 
            +
                  #
         | 
| 404 | 
            +
                  # Params:
         | 
| 405 | 
            +
                  #   start_date: string (YYYY-MM-DD)
         | 
| 406 | 
            +
                  #   end_date: string (YYYY-MM-DD)
         | 
| 407 | 
            +
                  #
         | 
| 408 | 
            +
                  # Response:
         | 
| 409 | 
            +
                  #   {
         | 
| 410 | 
            +
                  #      "result": {
         | 
| 411 | 
            +
                  #          "success": true,
         | 
| 412 | 
            +
                  #          "code": "000",
         | 
| 413 | 
            +
                  #          "message": "Sucesso"
         | 
| 414 | 
            +
                  #      },
         | 
| 415 | 
            +
                  #          "pagging": {
         | 
| 416 | 
            +
                  #          "limit": 6,
         | 
| 417 | 
            +
                  #          "count": 1,
         | 
| 418 | 
            +
                  #          "current": 1
         | 
| 419 | 
            +
                  #      },
         | 
| 420 | 
            +
                  #          "transactionsSummary": [
         | 
| 421 | 
            +
                  #          {
         | 
| 422 | 
            +
                  #              "date": "2018-01-19",
         | 
| 423 | 
            +
                  #              "brand": "Mastercard",
         | 
| 424 | 
            +
                  #              "paymentMethod": "CREDIT_CARD",
         | 
| 425 | 
            +
                  #              "status": "AUTHORIZED",
         | 
| 426 | 
            +
                  #              "count": 3,
         | 
| 427 | 
            +
                  #              "sum": 600,
         | 
| 428 | 
            +
                  #              "average": 200
         | 
| 429 | 
            +
                  #          },
         | 
| 430 | 
            +
                  #          {
         | 
| 431 | 
            +
                  #              "date": "2018-01-19",
         | 
| 432 | 
            +
                  #              "brand": "Mastercard",
         | 
| 433 | 
            +
                  #              "paymentMethod": "CREDIT_CARD",
         | 
| 434 | 
            +
                  #              "status": "CAPTURED",
         | 
| 435 | 
            +
                  #              "count": 3,
         | 
| 436 | 
            +
                  #              "sum": 300,
         | 
| 437 | 
            +
                  #              "average": 100
         | 
| 438 | 
            +
                  #          }]
         | 
| 439 | 
            +
                  #   }
         | 
| 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'))
         | 
| 441 | 
            +
                    log "Entrei em cards_summary_by_day"
         | 
| 442 | 
            +
                    # define o método de envio da requisição
         | 
| 443 | 
            +
                    method = :get
         | 
| 444 | 
            +
             | 
| 445 | 
            +
                    # monta a URL de chamada da requisição
         | 
| 446 | 
            +
                    endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:cards_summary_by_day]
         | 
| 447 | 
            +
                    endpoint =  endpoint.gsub("{startDate}", start_date).gsub("{endDate}", end_date)
         | 
| 448 | 
            +
             | 
| 449 | 
            +
                    # faz a chamada a plataforma de pagamento (MIDAS)
         | 
| 450 | 
            +
                    response = request(method, endpoint, self.login, self.password, {})
         | 
| 451 | 
            +
             | 
| 452 | 
            +
                    result = response[:result]
         | 
| 453 | 
            +
                    pagging = response[:pagging]
         | 
| 454 | 
            +
                    if response[:transactionsSummary].kind_of?(Array) || response[:transactionsSummary].blank?
         | 
| 455 | 
            +
                      transactions = response[:transactionsSummary]
         | 
| 456 | 
            +
                    else
         | 
| 457 | 
            +
                      transaction_array = []
         | 
| 458 | 
            +
                      transaction_array << response[:transactionsSummary]
         | 
| 459 | 
            +
                      transactions = transaction_array
         | 
| 460 | 
            +
                    end
         | 
| 461 | 
            +
             | 
| 462 | 
            +
                    response[:result] = result
         | 
| 463 | 
            +
                    response[:pagging] = pagging
         | 
| 464 | 
            +
                    response[:transactionsSummary] = transactions
         | 
| 465 | 
            +
             | 
| 466 | 
            +
                    response
         | 
| 467 | 
            +
                  end
         | 
| 468 | 
            +
             | 
| 469 | 
            +
                  #= 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.
         | 
| 470 | 
            +
                  #
         | 
| 471 | 
            +
                  # This is a is synchronous operation, using method GET
         | 
| 472 | 
            +
                  #
         | 
| 473 | 
            +
                  # Params:
         | 
| 474 | 
            +
                  #   start_month: string (MM)
         | 
| 475 | 
            +
                  #   end_month: string (MM)
         | 
| 476 | 
            +
                  #   start_year: string (YYYY)
         | 
| 477 | 
            +
                  #   end_year: string (YYYY)
         | 
| 478 | 
            +
                  #
         | 
| 479 | 
            +
                  # Response:
         | 
| 480 | 
            +
                  #   {
         | 
| 481 | 
            +
                  #      "result": {
         | 
| 482 | 
            +
                  #          "success": true,
         | 
| 483 | 
            +
                  #          "code": "000",
         | 
| 484 | 
            +
                  #          "message": "Sucesso"
         | 
| 485 | 
            +
                  #      },
         | 
| 486 | 
            +
                  #          "pagging": {
         | 
| 487 | 
            +
                  #          "limit": 6,
         | 
| 488 | 
            +
                  #          "count": 1,
         | 
| 489 | 
            +
                  #          "current": 1
         | 
| 490 | 
            +
                  #      },
         | 
| 491 | 
            +
                  #      "transactionsSummary": [
         | 
| 492 | 
            +
                  #       {
         | 
| 493 | 
            +
                  #           "year": 2018,
         | 
| 494 | 
            +
                  #           "month": 1,
         | 
| 495 | 
            +
                  #           "brand": "Mastercard",
         | 
| 496 | 
            +
                  #           "paymentMethod": "CREDIT_CARD",
         | 
| 497 | 
            +
                  #           "status": "AUTHORIZED",
         | 
| 498 | 
            +
                  #           "count": 3,
         | 
| 499 | 
            +
                  #           "sum": 600,
         | 
| 500 | 
            +
                  #           "average": 200
         | 
| 501 | 
            +
                  #       },
         | 
| 502 | 
            +
                  #       {
         | 
| 503 | 
            +
                  #           "year": 2018,
         | 
| 504 | 
            +
                  #           "month": 1,
         | 
| 505 | 
            +
                  #           "brand": "Mastercard",
         | 
| 506 | 
            +
                  #           "paymentMethod": "CREDIT_CARD",
         | 
| 507 | 
            +
                  #           "status": "CAPTURED",
         | 
| 508 | 
            +
                  #           "count": 3,
         | 
| 509 | 
            +
                  #           "sum": 300,
         | 
| 510 | 
            +
                  #           "average": 200
         | 
| 511 | 
            +
                  #       }]
         | 
| 512 | 
            +
                  #   }
         | 
| 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')))
         | 
| 514 | 
            +
                    log "Entrei em cards_summary_by_month"
         | 
| 515 | 
            +
                    # define o método de envio da requisição
         | 
| 516 | 
            +
                    method = :get
         | 
| 517 | 
            +
             | 
| 518 | 
            +
                    # monta a URL de chamada da requisição
         | 
| 519 | 
            +
                    endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:cards_summary_by_month]
         | 
| 520 | 
            +
                    endpoint =  endpoint.gsub("{startMonth}", start_month).gsub("{startYear}", start_year).gsub("{endMonth}", end_month).gsub("{endYear}", end_year)
         | 
| 521 | 
            +
             | 
| 522 | 
            +
                    # faz a chamada a plataforma de pagamento (MIDAS)
         | 
| 523 | 
            +
                    response = request(method, endpoint, self.login, self.password, {})
         | 
| 524 | 
            +
             | 
| 525 | 
            +
                    result = response[:result]
         | 
| 526 | 
            +
                    pagging = response[:pagging]
         | 
| 527 | 
            +
                    if response[:transactionsSummary].kind_of?(Array) || response[:transactionsSummary].blank?
         | 
| 528 | 
            +
                      transactions = response[:transactionsSummary]
         | 
| 36 529 | 
             
                    else
         | 
| 37 530 | 
             
                      transaction_array = []
         | 
| 38 | 
            -
                      transaction_array << response[: | 
| 531 | 
            +
                      transaction_array << response[:transactionsSummary]
         | 
| 39 532 | 
             
                      transactions = transaction_array
         | 
| 40 533 | 
             
                    end
         | 
| 41 534 |  | 
| 42 535 | 
             
                    response[:result] = result
         | 
| 43 536 | 
             
                    response[:pagging] = pagging
         | 
| 44 | 
            -
                    response[: | 
| 537 | 
            +
                    response[:transactionsSummary] = transactions
         | 
| 45 538 |  | 
| 46 539 | 
             
                    response
         | 
| 47 | 
            -
                end
         | 
| 48 | 
            -
             | 
| 49 | 
            -
                #= This method performs a query by a specific transaction's identifier, called external ID.
         | 
| 50 | 
            -
                # This is a is synchronous operation, using method GET
         | 
| 51 | 
            -
                #
         | 
| 52 | 
            -
                # Params:
         | 
| 53 | 
            -
                #   transactionToken: string (Transaction unique identification generated by customer)
         | 
| 54 | 
            -
                #
         | 
| 55 | 
            -
                #
         | 
| 56 | 
            -
                # Response:
         | 
| 57 | 
            -
                #   result: {
         | 
| 58 | 
            -
                #     success: true/false
         | 
| 59 | 
            -
                #     code: "XXX"
         | 
| 60 | 
            -
                #     message: "Some message to you"
         | 
| 61 | 
            -
                #   }
         | 
| 62 | 
            -
                def by_external_id(externalId)
         | 
| 63 | 
            -
                  log "Entrei em by_external_id"
         | 
| 64 | 
            -
             | 
| 65 | 
            -
                  # define o método de envio da requisição
         | 
| 66 | 
            -
                  method = :get
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                  # monta a URL de chamada da requisição
         | 
| 69 | 
            -
                  endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:by_external_id].gsub('{externalId}', externalId)
         | 
| 70 | 
            -
             | 
| 71 | 
            -
                  request(method, endpoint, login, password, {})
         | 
| 72 | 
            -
                end
         | 
| 73 | 
            -
             | 
| 74 | 
            -
                #= This method performs a query by an array of transaction's identifier.
         | 
| 75 | 
            -
                # This is a is synchronous operation, using method GET
         | 
| 76 | 
            -
                #
         | 
| 77 | 
            -
                # Params:
         | 
| 78 | 
            -
                #   none
         | 
| 79 | 
            -
                #
         | 
| 80 | 
            -
                #
         | 
| 81 | 
            -
                # Response:
         | 
| 82 | 
            -
                #   result: {
         | 
| 83 | 
            -
                #     success: true/false
         | 
| 84 | 
            -
                #     code: "XXX"
         | 
| 85 | 
            -
                #     message: "Some message to you"
         | 
| 86 | 
            -
                #   }
         | 
| 87 | 
            -
                def by_external_ids(externalIds = [])
         | 
| 88 | 
            -
                  log "Entrei em by_external_ids"
         | 
| 89 | 
            -
             | 
| 90 | 
            -
                  # define o método de envio da requisição
         | 
| 91 | 
            -
                  method = :post
         | 
| 92 | 
            -
             | 
| 93 | 
            -
                  # monta a URL de chamada da requisição
         | 
| 94 | 
            -
                  endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:by_external_ids]
         | 
| 95 | 
            -
             | 
| 96 | 
            -
                  request(method, endpoint, login, password, {externalIds: externalIds})
         | 
| 97 | 
            -
                end
         | 
| 98 | 
            -
             | 
| 99 | 
            -
                #= This method performs a query by an array of transaction's token.
         | 
| 100 | 
            -
                # This is a is synchronous operation, using method GET
         | 
| 101 | 
            -
                #
         | 
| 102 | 
            -
                # Params:
         | 
| 103 | 
            -
                #   none
         | 
| 104 | 
            -
                #
         | 
| 105 | 
            -
                #
         | 
| 106 | 
            -
                # Response:
         | 
| 107 | 
            -
                #   result: {
         | 
| 108 | 
            -
                #     success: true/false
         | 
| 109 | 
            -
                #     code: "XXX"
         | 
| 110 | 
            -
                #     message: "Some message to you"
         | 
| 111 | 
            -
                #   }
         | 
| 112 | 
            -
                def by_transaction_tokens(transactionTokens = [])
         | 
| 113 | 
            -
                  log "Entrei em by_external_ids"
         | 
| 114 | 
            -
             | 
| 115 | 
            -
                  # define o método de envio da requisição
         | 
| 116 | 
            -
                  method = :post
         | 
| 117 | 
            -
             | 
| 118 | 
            -
                  # monta a URL de chamada da requisição
         | 
| 119 | 
            -
                  endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:by_transaction_tokens]
         | 
| 120 | 
            -
             | 
| 121 | 
            -
                  request(method, endpoint, login, password, {transactionTokens: transactionTokens})
         | 
| 122 | 
            -
                end
         | 
| 123 | 
            -
             | 
| 124 | 
            -
                #= This method performs a query to return all subscriptions for a Point Of Sale by status
         | 
| 125 | 
            -
                # This is a is synchronous operation, using method GET
         | 
| 126 | 
            -
                #
         | 
| 127 | 
            -
                # Params:
         | 
| 128 | 
            -
                #   status: ACTIVE/CANCELLED
         | 
| 129 | 
            -
                #
         | 
| 130 | 
            -
                # Response:
         | 
| 131 | 
            -
                #   result: {
         | 
| 132 | 
            -
                #     success: true/false
         | 
| 133 | 
            -
                #     code: "XXX"
         | 
| 134 | 
            -
                #     message: "Some message to you"
         | 
| 135 | 
            -
                #   }
         | 
| 136 | 
            -
                def subscriptions(status = nil)
         | 
| 137 | 
            -
                  log "Entrei em subscriptions"
         | 
| 138 | 
            -
                  # define o método de envio da requisição
         | 
| 139 | 
            -
                  method = :get
         | 
| 140 | 
            -
             | 
| 141 | 
            -
                  # monta a URL de chamada da requisição
         | 
| 142 | 
            -
                  endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:subscriptions]
         | 
| 143 | 
            -
             | 
| 144 | 
            -
                  # monta os parâmetros da requisição na url
         | 
| 145 | 
            -
                  endpoint = status.blank? ? endpoint.gsub("status={status}", '') : endpoint.gsub("{status}", status)
         | 
| 146 | 
            -
             | 
| 147 | 
            -
                  # faz a chamada a plataforma de pagamento (MIDAS)
         | 
| 148 | 
            -
                  response = request(method, endpoint, self.login, self.password, {})
         | 
| 149 | 
            -
             | 
| 150 | 
            -
                  result = response[:result]
         | 
| 151 | 
            -
                  pagging = response[:pagging]
         | 
| 152 | 
            -
                  if response[:subscriptions].kind_of?(Array) || response[:subscriptions].blank?
         | 
| 153 | 
            -
                    subscriptions = response[:subscriptions]
         | 
| 154 | 
            -
                  else
         | 
| 155 | 
            -
                    subscription_array = []
         | 
| 156 | 
            -
                    subscription_array << response[:subscriptions]
         | 
| 157 | 
            -
                    subscriptions = subscription_array
         | 
| 158 540 | 
             
                  end
         | 
| 159 541 |  | 
| 160 | 
            -
                   | 
| 161 | 
            -
                   | 
| 162 | 
            -
                   | 
| 163 | 
            -
             | 
| 164 | 
            -
                   | 
| 165 | 
            -
             | 
| 166 | 
            -
             | 
| 167 | 
            -
             | 
| 168 | 
            -
             | 
| 169 | 
            -
             | 
| 170 | 
            -
             | 
| 171 | 
            -
             | 
| 172 | 
            -
             | 
| 173 | 
            -
             | 
| 174 | 
            -
             | 
| 175 | 
            -
             | 
| 176 | 
            -
             | 
| 177 | 
            -
             | 
| 178 | 
            -
             | 
| 179 | 
            -
             | 
| 180 | 
            -
             | 
| 181 | 
            -
             | 
| 182 | 
            -
             | 
| 183 | 
            -
             | 
| 184 | 
            -
             | 
| 185 | 
            -
             | 
| 186 | 
            -
             | 
| 187 | 
            -
             | 
| 188 | 
            -
             | 
| 189 | 
            -
             | 
| 190 | 
            -
             | 
| 191 | 
            -
             | 
| 192 | 
            -
             | 
| 193 | 
            -
                   | 
| 194 | 
            -
                  #  | 
| 195 | 
            -
                   | 
| 196 | 
            -
             | 
| 197 | 
            -
                  #  | 
| 198 | 
            -
                   | 
| 199 | 
            -
             | 
| 200 | 
            -
                   | 
| 201 | 
            -
             | 
| 202 | 
            -
             | 
| 203 | 
            -
             | 
| 204 | 
            -
             | 
| 205 | 
            -
             | 
| 206 | 
            -
             | 
| 207 | 
            -
             | 
| 208 | 
            -
                #   none
         | 
| 209 | 
            -
                #
         | 
| 210 | 
            -
                # Response:
         | 
| 211 | 
            -
                #   result: {
         | 
| 212 | 
            -
                #     success: true/false
         | 
| 213 | 
            -
                #     code: "XXX"
         | 
| 214 | 
            -
                #     message: "Some message to you"
         | 
| 215 | 
            -
                #   }
         | 
| 216 | 
            -
                #   creditCards: [
         | 
| 217 | 
            -
                #   {
         | 
| 218 | 
            -
                #      brand: "MASTER",
         | 
| 219 | 
            -
                #      panLastDigits": "4832",
         | 
| 220 | 
            -
                #      expirationMonth": 10,
         | 
| 221 | 
            -
                #      expirationYear": 2019,
         | 
| 222 | 
            -
                #      holderName": "Nome Portador",
         | 
| 223 | 
            -
                #      customer: {
         | 
| 224 | 
            -
                #         documentType: "CPF",
         | 
| 225 | 
            -
                #         documentNumber: "12345678900"
         | 
| 226 | 
            -
                #      },
         | 
| 227 | 
            -
                #      token: "b7553c62bc93ed0708b4behfcf28f3592"
         | 
| 228 | 
            -
                #    }
         | 
| 229 | 
            -
                def list_customers()
         | 
| 230 | 
            -
                  log "Entrei em list_customers"
         | 
| 231 | 
            -
                  # define o método de envio da requisição
         | 
| 232 | 
            -
                  method = :get
         | 
| 233 | 
            -
             | 
| 234 | 
            -
                  # monta a URL de chamada da requisição
         | 
| 235 | 
            -
                  endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:customers]
         | 
| 236 | 
            -
             | 
| 237 | 
            -
                  # faz a chamada a plataforma de pagamento (MIDAS)
         | 
| 238 | 
            -
                  request(method, endpoint, self.login, self.password, {})
         | 
| 239 | 
            -
                end
         | 
| 542 | 
            +
                  #= This method performs a query that summarizes all billet's operations between a date period by DATE, BANK, PAYMENT_METHOD and STATUS.
         | 
| 543 | 
            +
                  #
         | 
| 544 | 
            +
                  # This is a is synchronous operation, using method GET
         | 
| 545 | 
            +
                  #
         | 
| 546 | 
            +
                  # Params:
         | 
| 547 | 
            +
                  #   start_date: string (YYYY-MM-DD)
         | 
| 548 | 
            +
                  #   end_date: string (YYYY-MM-DD)
         | 
| 549 | 
            +
                  #
         | 
| 550 | 
            +
                  # Response:
         | 
| 551 | 
            +
                  #   {
         | 
| 552 | 
            +
                  #      "result": {
         | 
| 553 | 
            +
                  #          "success": true,
         | 
| 554 | 
            +
                  #          "code": "000",
         | 
| 555 | 
            +
                  #          "message": "Sucesso"
         | 
| 556 | 
            +
                  #      },
         | 
| 557 | 
            +
                  #          "pagging": {
         | 
| 558 | 
            +
                  #          "limit": 6,
         | 
| 559 | 
            +
                  #          "count": 1,
         | 
| 560 | 
            +
                  #          "current": 1
         | 
| 561 | 
            +
                  #      },
         | 
| 562 | 
            +
                  #          "transactionsSummary": [
         | 
| 563 | 
            +
                  #          {
         | 
| 564 | 
            +
                  #              "date": "2018-01-19",
         | 
| 565 | 
            +
                  #              "brand": "Mastercard",
         | 
| 566 | 
            +
                  #              "paymentMethod": "CREDIT_CARD",
         | 
| 567 | 
            +
                  #              "status": "AUTHORIZED",
         | 
| 568 | 
            +
                  #              "count": 3,
         | 
| 569 | 
            +
                  #              "sum": 600,
         | 
| 570 | 
            +
                  #              "average": 200
         | 
| 571 | 
            +
                  #          },
         | 
| 572 | 
            +
                  #          {
         | 
| 573 | 
            +
                  #              "date": "2018-01-19",
         | 
| 574 | 
            +
                  #              "brand": "Mastercard",
         | 
| 575 | 
            +
                  #              "paymentMethod": "CREDIT_CARD",
         | 
| 576 | 
            +
                  #              "status": "CAPTURED",
         | 
| 577 | 
            +
                  #              "count": 3,
         | 
| 578 | 
            +
                  #              "sum": 300,
         | 
| 579 | 
            +
                  #              "average": 100
         | 
| 580 | 
            +
                  #          }]
         | 
| 581 | 
            +
                  #   }
         | 
| 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'))
         | 
| 583 | 
            +
                    log "Entrei em billets_summary_by_day"
         | 
| 584 | 
            +
                    # define o método de envio da requisição
         | 
| 585 | 
            +
                    method = :get
         | 
| 586 | 
            +
             | 
| 587 | 
            +
                    # monta a URL de chamada da requisição
         | 
| 588 | 
            +
                    endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:billets_summary_by_day]
         | 
| 589 | 
            +
                    endpoint =  endpoint.gsub("{startDate}", start_date).gsub("{endDate}", end_date)
         | 
| 240 590 |  | 
| 591 | 
            +
                    # faz a chamada a plataforma de pagamento (MIDAS)
         | 
| 592 | 
            +
                    response = request(method, endpoint, self.login, self.password, {})
         | 
| 241 593 |  | 
| 594 | 
            +
                    result = response[:result]
         | 
| 595 | 
            +
                    pagging = response[:pagging]
         | 
| 596 | 
            +
                    if response[:transactionsSummary].kind_of?(Array) || response[:transactionsSummary].blank?
         | 
| 597 | 
            +
                      transactions = response[:transactionsSummary]
         | 
| 598 | 
            +
                    else
         | 
| 599 | 
            +
                      transaction_array = []
         | 
| 600 | 
            +
                      transaction_array << response[:transactionsSummary]
         | 
| 601 | 
            +
                      transactions = transaction_array
         | 
| 602 | 
            +
                    end
         | 
| 603 | 
            +
             | 
| 604 | 
            +
                    response[:result] = result
         | 
| 605 | 
            +
                    response[:pagging] = pagging
         | 
| 606 | 
            +
                    response[:transactionsSummary] = transactions
         | 
| 607 | 
            +
             | 
| 608 | 
            +
                    response
         | 
| 609 | 
            +
                  end
         | 
| 610 | 
            +
             | 
| 611 | 
            +
                  #= This method performs a query that summarizes all billet's operations between a date period by MONTH, BANK, PAYMENT_METHOD and STATUS.
         | 
| 612 | 
            +
                  #
         | 
| 613 | 
            +
                  # This is a is synchronous operation, using method GET
         | 
| 614 | 
            +
                  #
         | 
| 615 | 
            +
                  # Params:
         | 
| 616 | 
            +
                  #   start_month: string (MM)
         | 
| 617 | 
            +
                  #   end_month: string (MM)
         | 
| 618 | 
            +
                  #   start_year: string (YYYY)
         | 
| 619 | 
            +
                  #   end_year: string (YYYY)
         | 
| 620 | 
            +
                  #
         | 
| 621 | 
            +
                  # Response:
         | 
| 622 | 
            +
                  #   {
         | 
| 623 | 
            +
                  #      "result": {
         | 
| 624 | 
            +
                  #          "success": true,
         | 
| 625 | 
            +
                  #          "code": "000",
         | 
| 626 | 
            +
                  #          "message": "Sucesso"
         | 
| 627 | 
            +
                  #      },
         | 
| 628 | 
            +
                  #          "pagging": {
         | 
| 629 | 
            +
                  #          "limit": 6,
         | 
| 630 | 
            +
                  #          "count": 1,
         | 
| 631 | 
            +
                  #          "current": 1
         | 
| 632 | 
            +
                  #      },
         | 
| 633 | 
            +
                  #      "transactionsSummary": [
         | 
| 634 | 
            +
                  #       {
         | 
| 635 | 
            +
                  #           "year": 2018,
         | 
| 636 | 
            +
                  #           "month": 1,
         | 
| 637 | 
            +
                  #           "brand": "Mastercard",
         | 
| 638 | 
            +
                  #           "paymentMethod": "CREDIT_CARD",
         | 
| 639 | 
            +
                  #           "status": "AUTHORIZED",
         | 
| 640 | 
            +
                  #           "count": 3,
         | 
| 641 | 
            +
                  #           "sum": 600,
         | 
| 642 | 
            +
                  #           "average": 200
         | 
| 643 | 
            +
                  #       },
         | 
| 644 | 
            +
                  #       {
         | 
| 645 | 
            +
                  #           "year": 2018,
         | 
| 646 | 
            +
                  #           "month": 1,
         | 
| 647 | 
            +
                  #           "brand": "Mastercard",
         | 
| 648 | 
            +
                  #           "paymentMethod": "CREDIT_CARD",
         | 
| 649 | 
            +
                  #           "status": "CAPTURED",
         | 
| 650 | 
            +
                  #           "count": 3,
         | 
| 651 | 
            +
                  #           "sum": 300,
         | 
| 652 | 
            +
                  #           "average": 200
         | 
| 653 | 
            +
                  #       }]
         | 
| 654 | 
            +
                  #   }
         | 
| 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')))
         | 
| 656 | 
            +
                    log "Entrei em billets_summary_by_month"
         | 
| 657 | 
            +
                    # define o método de envio da requisição
         | 
| 658 | 
            +
                    method = :get
         | 
| 659 | 
            +
             | 
| 660 | 
            +
                    # monta a URL de chamada da requisição
         | 
| 661 | 
            +
                    endpoint =  get_env[:url] + EndPoints::QUERIES[:context] + EndPoints::QUERIES[:billets_summary_by_month]
         | 
| 662 | 
            +
                    endpoint =  endpoint.gsub("{startMonth}", start_month).gsub("{startYear}", start_year).gsub("{endMonth}", end_month).gsub("{endYear}", end_year)
         | 
| 663 | 
            +
             | 
| 664 | 
            +
                    # faz a chamada a plataforma de pagamento (MIDAS)
         | 
| 665 | 
            +
                    response = request(method, endpoint, self.login, self.password, {})
         | 
| 666 | 
            +
             | 
| 667 | 
            +
                    result = response[:result]
         | 
| 668 | 
            +
                    pagging = response[:pagging]
         | 
| 669 | 
            +
                    if response[:transactionsSummary].kind_of?(Array) || response[:transactionsSummary].blank?
         | 
| 670 | 
            +
                      transactions = response[:transactionsSummary]
         | 
| 671 | 
            +
                    else
         | 
| 672 | 
            +
                      transaction_array = []
         | 
| 673 | 
            +
                      transaction_array << response[:transactionsSummary]
         | 
| 674 | 
            +
                      transactions = transaction_array
         | 
| 675 | 
            +
                    end
         | 
| 676 | 
            +
             | 
| 677 | 
            +
                    response[:result] = result
         | 
| 678 | 
            +
                    response[:pagging] = pagging
         | 
| 679 | 
            +
                    response[:transactionsSummary] = transactions
         | 
| 680 | 
            +
             | 
| 681 | 
            +
                    response
         | 
| 682 | 
            +
                  end
         | 
| 242 683 | 
             
              end
         | 
| 243 684 | 
             
            end
         |