Sha256: 57dfd3c9d2b5abe7944426aed1d3d3aac3d190a168f4a3034077cfabd7897de3

Contents?: true

Size: 811 Bytes

Versions: 1

Compression:

Stored size: 811 Bytes

Contents

module NedbankApi
  class ApiWrapper
    class << self
      def idempotency_key
        rand.to_s[2..24]
      end

      def auth_headers(overrides={})
        {
          "Content-Type" => "application/json",
          "accept" => 'application/json',
          "x-fapi-financial-id" => "OB/2017/001",
          "x-idempotency-key" => idempotency_key,
          "Authorization" => "Bearer #{NedbankApi.intent_token.access_token}",
          "x-ibm-client-id" => NedbankApi.configuration.client_id,
          "x-ibm-client-secret" => NedbankApi.configuration.client_secret
        }.merge(overrides)
      end

      def endpoint(path)
        NedbankApi.configuration.api_endpoint + path
      end

      def json_to_object(json)
        JSON.parse(json, object_class: OpenStruct)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nedbank_api-0.2.2 lib/nedbank_api/api_wrapper.rb