Module: PayPoint::Blue

Defined in:
lib/paypoint/blue.rb,
lib/paypoint/blue/base.rb,
lib/paypoint/blue/error.rb,
lib/paypoint/blue/utils.rb,
lib/paypoint/blue/version.rb,
lib/paypoint/blue/raise_errors.rb,
lib/paypoint/blue/body_extractor.rb,
lib/paypoint/blue/payload_builder.rb,
lib/paypoint/blue/hash_key_converter.rb

Overview

Top level module with helper methods.

Defined Under Namespace

Modules: PayloadBuilder, Utils Classes: API, Base, BodyExtractor, Error, HashKeyConverter, Hosted, RaiseErrors

Constant Summary collapse

VERSION =
"1.0.4".freeze

Class Method Summary collapse

Class Method Details

.api_client(**options) ⇒ Object

Creates a client for the PayPoint Blue API product



16
17
18
# File 'lib/paypoint/blue.rb', line 16

def self.api_client(**options)
  PayPoint::Blue::API.new(**options)
end

.hosted_client(**options) ⇒ Object

Creates a client for the PayPoint Blue Hosted product



23
24
25
# File 'lib/paypoint/blue.rb', line 23

def self.hosted_client(**options)
  PayPoint::Blue::Hosted.new(**options)
end

.parse_payload(json) ⇒ Hashie::Mash

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

Returns:

  • (Hashie::Mash)

    the parsed, snake_cased response



31
32
33
34
35
36
37
38
39
# 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