Module: Payload

Defined in:
lib/payload.rb,
lib/payload/utils.rb,
lib/payload/objects.rb,
lib/payload/version.rb,
lib/payload/arm/object.rb,
lib/payload/exceptions.rb,
lib/payload/arm/request.rb,
lib/payload/arm/session.rb

Defined Under Namespace

Classes: ARMObject, ARMObjectWrapper, ARMRequest, AccessToken, Account, BadRequest, BankAccount, BillingCharge, BillingSchedule, Card, ChargeItem, ClientToken, Customer, Forbidden, InternalServerError, InvalidAttributes, Invoice, Ledger, LineItem, NotFound, OAuthToken, Org, PayloadError, Payment, PaymentActivation, PaymentItem, PaymentLink, PaymentMethod, ProcessingAccount, Refund, ServiceUnavailable, Session, TooManyRequests, Transaction, Unauthorized, UnknownResponse, Webhook

Constant Summary collapse

VERSION =
'0.4.1'

Class Method Summary collapse

Class Method Details

.api_keyObject


13
14
15
# File 'lib/payload.rb', line 13

def api_key
  session.api_key
end

.api_key=(value) ⇒ Object


9
10
11
# File 'lib/payload.rb', line 9

def api_key=(value)
  session.api_key = value
end

.api_urlObject


21
22
23
# File 'lib/payload.rb', line 21

def api_url
  session.api_url
end

.api_url=(value) ⇒ Object


17
18
19
# File 'lib/payload.rb', line 17

def api_url=(value)
  session.api_url = value
end

.create(objects) ⇒ Object


36
37
38
# File 'lib/payload.rb', line 36

def self.create(objects)
  return Payload::ARMRequest.new().create(objects)
end

.delete(objects) ⇒ Object


44
45
46
# File 'lib/payload.rb', line 44

def self.delete(objects)
  return Payload::ARMRequest.new().delete_all(objects)
end

.get_cls(data) ⇒ Object


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/payload/utils.rb', line 7

def self.get_cls(data)
  match = nil
  for cls in subclasses(Payload::ARMObject)
    if cls.spec&.fetch('object') != data['object']
      next
    end

    if not cls.poly and not match
      match = cls

    elsif cls.poly

      invalid = false
      cls.poly.each do |key, value|
        if data[key] != value
          invalid = true
        end
      end

      if invalid
        next
      end

      match = cls
      break
    end
  end

  match
end

.subclasses(super_cls) ⇒ Object


3
4
5
# File 'lib/payload/utils.rb', line 3

def self.subclasses(super_cls)
  ObjectSpace.each_object(Class).select { |cls| cls < super_cls }
end

.update(objects) ⇒ Object


40
41
42
# File 'lib/payload.rb', line 40

def self.update(objects)
  return Payload::ARMRequest.new().update_all(objects)
end

.URLObject


25
26
27
# File 'lib/payload.rb', line 25

def URL
  @URL
end