Class: Wizypay::Merchant

Inherits:
Resource
  • Object
show all
Defined in:
lib/wizypay/merchant.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#reinitialize

Class Method Details

.all(q = {}) ⇒ Object



8
9
10
# File 'lib/wizypay/merchant.rb', line 8

def self.all(q = {})
  where(q)
end

.where(q) ⇒ Object



3
4
5
6
# File 'lib/wizypay/merchant.rb', line 3

def self.where(q)
  raw = ApiClient.get('/merchants', q)
  Collection.new(self, raw[:data], raw[:meta])
end

Instance Method Details

#adsObject



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

def ads
  Collection.new(Ad, super['data'], super['meta'])
end

#categoriesObject



28
29
30
# File 'lib/wizypay/merchant.rb', line 28

def categories
  Collection.new(MerchantCategory, super['data'], super['meta'])
end

#network_updated_atObject



32
33
34
35
# File 'lib/wizypay/merchant.rb', line 32

def network_updated_at
  return nil unless super.present?
  Time.parse(super)
end

#primary_adObject



16
17
18
# File 'lib/wizypay/merchant.rb', line 16

def primary_ad
  Resource.new(super['data'])
end

#primary_ad_idObject



20
21
22
# File 'lib/wizypay/merchant.rb', line 20

def primary_ad_id
  super || primary_ad.id || ads.first.try(:id)
end

#versionsObject



12
13
14
# File 'lib/wizypay/merchant.rb', line 12

def versions
  MerchantVersion.for(self)
end