module PayPoint::Blue

Top level module with helper methods.

Constants

VERSION

Public Class Methods

api_client(**options) click to toggle source

Creates a client for the PayPoint Blue API product

@see PayPoint::Blue::Base#initialize

# File lib/paypoint/blue.rb, line 16
def self.api_client(**options)
  PayPoint::Blue::API.new(**options)
end
hosted_client(**options) click to toggle source

Creates a client for the PayPoint Blue Hosted product

@see PayPoint::Blue::Base#initialize

# File lib/paypoint/blue.rb, line 23
def self.hosted_client(**options)
  PayPoint::Blue::Hosted.new(**options)
end
parse_payload(json) click to toggle source

Parse a raw JSON PayPoint callback payload similarly to the Faraday response middlewares set up in {PayPoint::Blue::Base}.

@return [Hashie::Mash] the parsed, snake_cased response

# File lib/paypoint/blue.rb, line 31
def self.parse_payload(json)
  payload = json.respond_to?(:read) ? json.read : json.to_s
  if payload.encoding == Encoding::ASCII_8BIT
    payload.force_encoding "iso-8859-1"
  end
  payload = JSON.parse(payload)
  payload = Utils.snakecase_and_symbolize_keys(payload)
  Hashie::Mash.new(payload)
end