Class: Inttegro::Resources::Prices

Inherits:
Object
  • Object
show all
Defined in:
lib/inttegro/resources/prices.rb

Overview

Client for catalog prices and their lifecycle.

Access this resource through Client#prices.

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ Prices

Returns a new instance of Prices.

Parameters:



11
12
13
# File 'lib/inttegro/resources/prices.rb', line 11

def initialize(http)
  @http = T.let(http, Inttegro::HTTPClient)
end

Instance Method Details

#activate(price_id:) ⇒ Inttegro::Price::CatalogPrice

Reactivate an inactive price.

Parameters:

  • price_id (String) —

    unique price identifier

Returns:



75
76
77
78
79
80
81
82
83
84
85
# File 'lib/inttegro/resources/prices.rb', line 75

def activate(price_id:)
  T.cast(
    @http.post_union_resource(
      "/prices/activate",
      [Inttegro::Price::Fixed, Inttegro::Customer::SelectedCatalogPrice],
      :price,
      { price_id: price_id }
    ),
    Inttegro::Price::CatalogPrice
  )
end

#archive(price_id:) ⇒ Inttegro::Price::CatalogPrice

Archive a price and mark it inactive.

Parameters:

  • price_id (String) —

    unique price identifier

Returns:



107
108
109
110
111
112
113
114
115
116
117
# File 'lib/inttegro/resources/prices.rb', line 107

def archive(price_id:)
  T.cast(
    @http.post_union_resource(
      "/prices/archive",
      [Inttegro::Price::Fixed, Inttegro::Customer::SelectedCatalogPrice],
      :price,
      { price_id: price_id }
    ),
    Inttegro::Price::CatalogPrice
  )
end

#create(payload) ⇒ Inttegro::Price::CatalogPrice

Create a catalog price.

Parameters:

Returns:



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/inttegro/resources/prices.rb', line 19

def create(payload)
  T.cast(
    @http.post_union_resource(
      "/prices/create",
      [Inttegro::Price::Fixed, Inttegro::Customer::SelectedCatalogPrice],
      :price,
      payload
    ),
    Inttegro::Price::CatalogPrice
  )
end

#deactivate(price_id:) ⇒ Inttegro::Price::CatalogPrice

Deactivate a price for new active catalog flows.

Parameters:

  • price_id (String) —

    unique price identifier

Returns:



91
92
93
94
95
96
97
98
99
100
101
# File 'lib/inttegro/resources/prices.rb', line 91

def deactivate(price_id:)
  T.cast(
    @http.post_union_resource(
      "/prices/deactivate",
      [Inttegro::Price::Fixed, Inttegro::Customer::SelectedCatalogPrice],
      :price,
      { price_id: price_id }
    ),
    Inttegro::Price::CatalogPrice
  )
end

#lookup(price_id:) ⇒ Inttegro::Price::CatalogPrice

Retrieve one catalog price.

Parameters:

  • price_id (String) —

    unique price identifier

Returns:



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/inttegro/resources/prices.rb', line 35

def lookup(price_id:)
  T.cast(
    @http.post_union_resource(
      "/prices/lookup",
      [Inttegro::Price::Fixed, Inttegro::Customer::SelectedCatalogPrice],
      :price,
      { price_id: price_id }
    ),
    Inttegro::Price::CatalogPrice
  )
end

#page(payload = {}) ⇒ Inttegro::Price::Page

Retrieve a page of catalog prices.

Parameters:

Returns:



51
52
53
# File 'lib/inttegro/resources/prices.rb', line 51

def page(payload = {})
  @http.post_resource("/prices/page", Inttegro::Price::Page, :page, payload || {})
end

#update(payload) ⇒ Inttegro::Price::CatalogPrice

Update mutable price metadata.

Parameters:

Returns:



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/inttegro/resources/prices.rb', line 59

def update(payload)
  T.cast(
    @http.post_union_resource(
      "/prices/update",
      [Inttegro::Price::Fixed, Inttegro::Customer::SelectedCatalogPrice],
      :price,
      payload
    ),
    Inttegro::Price::CatalogPrice
  )
end