Class: Inttegro::Resources::PurchaseIntents

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

Overview

Client for controlled, shareable purchase intents and hosted Buy links.

Access this resource through Client#purchase_intents.

Instance Method Summary collapse

Constructor Details

#initialize(http) ⇒ PurchaseIntents

Returns a new instance of PurchaseIntents.

Parameters:



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

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

Instance Method Details

#cancel(id:) ⇒ Inttegro::PurchaseIntent

Stop a purchase intent from creating new orders.

Parameters:

  • id (String) —

    unique purchase intent identifier

Returns:



35
36
37
38
39
40
41
# File 'lib/inttegro/resources/purchase_intents.rb', line 35

def cancel(id:)
  @http.post_resource(
    "/purchase_intents/cancel",
    Inttegro::PurchaseIntent, :purchase_intent,
    { id: id }
  )
end

#create(payload) ⇒ Inttegro::PurchaseIntent

Create a purchase intent for a catalog product.

Parameters:

Returns:



19
20
21
# File 'lib/inttegro/resources/purchase_intents.rb', line 19

def create(payload)
  @http.post_resource("/purchase_intents/create", Inttegro::PurchaseIntent, :purchase_intent, payload)
end

#lookup(id:) ⇒ Inttegro::PurchaseIntent

Retrieve a purchase intent by its opaque identifier.

Parameters:

  • id (String) —

    unique purchase intent identifier

Returns:



47
48
49
50
51
52
53
# File 'lib/inttegro/resources/purchase_intents.rb', line 47

def lookup(id:)
  @http.post_resource(
    "/purchase_intents/lookup",
    Inttegro::PurchaseIntent, :purchase_intent,
    { id: id }
  )
end

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

Retrieve purchase intents in newest-first order.

Parameters:

Returns:



59
60
61
62
63
64
65
# File 'lib/inttegro/resources/purchase_intents.rb', line 59

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

#update(payload) ⇒ Inttegro::PurchaseIntent

Change mutable quantity or expiry fields on a purchase intent.

Parameters:

Returns:



27
28
29
# File 'lib/inttegro/resources/purchase_intents.rb', line 27

def update(payload)
  @http.post_resource("/purchase_intents/update", Inttegro::PurchaseIntent, :purchase_intent, payload)
end