Class: ShopifyOracle::Accessor::SubscriptionDraft

Inherits:
Base
  • Object
show all
Defined in:
lib/shopify_oracle/accessor/subscription_draft.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#gid, #object

Instance Method Summary collapse

Methods inherited from Base

class_name, find, list

Constructor Details

#initialize(id:) ⇒ SubscriptionDraft

Returns a new instance of SubscriptionDraft.



10
11
12
13
# File 'lib/shopify_oracle/accessor/subscription_draft.rb', line 10

def initialize(id:)
  super
  @draft = @object
end

Instance Attribute Details

#draftObject (readonly)

Returns the value of attribute draft.



8
9
10
# File 'lib/shopify_oracle/accessor/subscription_draft.rb', line 8

def draft
  @draft
end

Instance Method Details

#add_line_item(productVariantId:, currentPrice:, quantity:) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/shopify_oracle/accessor/subscription_draft.rb', line 45

def add_line_item(
  productVariantId:,
  currentPrice:,
  quantity:
)
  productVariantId = "gid://shopify/ProductVariant/#{productVariantId}" if productVariantId.is_a?(Integer)
  input = {
    productVariantId:,
    quantity:,
    currentPrice:
  }

  @oracle.mutate(:add_line_item_to_subscription_draft, draftId: @id, input:)
end

#commitObject



20
21
22
23
24
25
# File 'lib/shopify_oracle/accessor/subscription_draft.rb', line 20

def commit
  @oracle.mutate(
    :subscription_draft_commit,
    draftId: @gid
  )
end

#reloadObject



15
16
17
18
# File 'lib/shopify_oracle/accessor/subscription_draft.rb', line 15

def reload
  super
  @draft = @object
end

#update_delivery_method(address:) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/shopify_oracle/accessor/subscription_draft.rb', line 27

def update_delivery_method(
  address:
)
  input = {
    deliveryMethod: {
      shipping: {
        address:
      }
    }
  }

  @oracle.mutate(
    :subscription_draft_update,
    draftId: @gid,
    input:
  )
end