Class: ShopifyOracle::Accessor::SubscriptionDraft
- Defined in:
- lib/shopify_oracle/accessor/subscription_draft.rb
Instance Attribute Summary collapse
-
#draft ⇒ Object
readonly
Returns the value of attribute draft.
Attributes inherited from Base
Instance Method Summary collapse
- #add_line_item(productVariantId:, currentPrice:, quantity:) ⇒ Object
- #commit ⇒ Object
-
#initialize(id:) ⇒ SubscriptionDraft
constructor
A new instance of SubscriptionDraft.
- #reload ⇒ Object
- #update_delivery_method(address:) ⇒ Object
Methods inherited from Base
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
#draft ⇒ Object (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 |
#commit ⇒ Object
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 |
#reload ⇒ Object
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 |