Sha256: c542d43fb8affcb2a436a036e099522f6b58ce160abd5f2325c7cbeeee64fdf9

Contents?: true

Size: 921 Bytes

Versions: 1

Compression:

Stored size: 921 Bytes

Contents

module Paydunya
  module Utilities

    def connection
      Faraday.new(url: Paydunya::Setup.root_url,
                  ssl: { verify: false },
                  headers: {
                    'Content-Type' => 'application/json',
                    'User-Agent' => 'Paydunya Checkout API Ruby client v1 aka Neptune',
                    'PAYDUNYA-PUBLIC-KEY' => Paydunya::Setup.public_key,
                    'PAYDUNYA-PRIVATE-KEY' => Paydunya::Setup.private_key,
                    'PAYDUNYA-MASTER-KEY' => Paydunya::Setup.master_key,
                    'PAYDUNYA-TOKEN' => Paydunya::Setup.token,
                    'PAYDUNYA-MODE' => Paydunya::Setup.mode
                  })
    end

    def send_post_request(url, payload = {})
      JSON.parse connection.post(url, payload.to_json).body
    end

    def send_get_request(url, params = nil)
      JSON.parse connection.get(url, params).body
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paydunya-1.0.6 lib/paydunya/utilities.rb