module Pwinty

Constants

API_KEY
API_VERSION
BASE_URL
DEFAULT_PAGE_SIZE
MERCHANT_ID
VERSION

Attributes

logger[RW]

Public Class Methods

collate_results(response_data, targetted_class) click to toggle source
# File lib/pwinty.rb, line 54
def self.collate_results(response_data, targetted_class)
  collection = []
  response_data.each do |individual_attr|
    collection << targetted_class.new(individual_attr)
  end
  collection
end
conn() click to toggle source
# File lib/pwinty.rb, line 45
def self.conn
  Faraday.new(url: url, headers: headers) do |config|
    config.request :json
    config.response :json
    config.use Pwinty::HttpErrors
    config.adapter Faraday.default_adapter
  end
end
headers() click to toggle source
# File lib/pwinty.rb, line 39
def self.headers
  {
    'X-API-Key' => Pwinty::API_KEY,
  }
end
url() click to toggle source
# File lib/pwinty.rb, line 35
def self.url
  "#{Pwinty::BASE_URL}/#{Pwinty::API_VERSION}/"
end

Protected Class Methods

is_limit_reached(number_of_records, limit: 0) click to toggle source
# File lib/pwinty/api_models/order.rb, line 109
def self.is_limit_reached(number_of_records, limit: 0)
  return false if limit === 0
  return number_of_records >= limit
end