Class: Vng::PriceList

Inherits:
Resource show all
Defined in:
lib/vng/price_list.rb

Overview

Provides methods to interact with Vonigo price lists.

Constant Summary collapse

PATH =
'/api/v1/resources/priceLists/'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, name:) ⇒ PriceList

Returns a new instance of PriceList.



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

def initialize(id:, name:)
  @id = id
  @name = name
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/vng/price_list.rb', line 8

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



8
9
10
# File 'lib/vng/price_list.rb', line 8

def name
  @name
end

Class Method Details

.allObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/vng/price_list.rb', line 15

def self.all
  data = request path: PATH

  data.fetch('PriceLists', []).filter_map do |price_list|
    next unless price_list['isActive']
    next unless price_list['serviceTypeID'].eql?(14)

    id = price_list['priceListID']
    name = price_list['priceList']

    new id: id, name: name
  end
end