Sha256: 179837a6454d14c68f7dc3424f21f779f7a4c0f4b8d5b22f91468b1696b88285

Contents?: true

Size: 765 Bytes

Versions: 6

Compression:

Stored size: 765 Bytes

Contents

module GmanClient
  module Utility
    def request
      Blanket.wrap(
        @url,
        extension: :json,
        headers: { 'Authorization' => "Bearer #{token}" }
      )
    end

    def token
      return @token if @token

      response = RestClient.post(@token_url,
                                 grant_type: 'client_credentials',
                                 client_id: @client_id,
                                 client_secret: @client_secret)

      @token = JSON.parse(response)['access_token']
    end

    def convert_payload(response)
      response.map do |hash_request|
        Hashie.symbolize_keys!(hash_request.to_h)
      end
    end

    def attempt(retry_count)
      with_retries(max_tries: retry_count) { yield }
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gman_client-0.2.1 lib/gman_client/utility.rb
gman_client-0.2.0 lib/gman_client/utility.rb
gman_client-0.0.10 lib/gman_client/utility.rb
gman_client-0.0.9 lib/gman_client/utility.rb
gman_client-0.0.8 lib/gman_client/utility.rb
gman_client-0.0.7 lib/gman_client/utility.rb