Class: Giftbit

Inherits:
Object
  • Object
show all
Extended by:
Base, Methods
Includes:
Base, Methods
Defined in:
lib/giftbit.rb,
lib/giftbit/base.rb,
lib/giftbit/version.rb

Defined Under Namespace

Modules: Base, Methods

Constant Summary collapse

VERSION =
'1.0.0'

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Base

auths?, extended, get_auth, included, inherited_auth, inherited_endpoint, instance?

Methods included from Methods

account, campaign, create_gift, delete_gift, funds, get_links, gifts, marketplace, regions, resend_gift, vendors

Constructor Details

#initialize(auth:) ⇒ Giftbit

Class-level methods only work if you have a single API account. This lets you instantiate the API for a given account, if you have multiple.



10
11
12
13
# File 'lib/giftbit.rb', line 10

def initialize(auth:)
  fail 'no auths set' unless auths = self.class.auths
  self.auth = auths.fetch(auth)
end

Class Method Details

.each_authObject

This lets you call the same API requests on every account you have. This is useful e.g. to check the status of every gift in every account.



17
18
19
20
21
22
# File 'lib/giftbit.rb', line 17

def self.each_auth
  fail 'no auths set' unless auths
  auths.each do |name, _|
    yield new auth: name
  end
end

Instance Method Details

#==(other) ⇒ Object



24
25
26
# File 'lib/giftbit.rb', line 24

def ==(other)
  other.is_a?(Giftbit) && auth == other.auth
end