Class: ShopifyOracle::Accessor::SubscriptionContract
- Defined in:
- lib/shopify_oracle/accessor/subscription_contract.rb
Instance Attribute Summary collapse
-
#contract ⇒ Object
readonly
Returns the value of attribute contract.
Attributes inherited from Base
Class Method Summary collapse
-
.create(customer:, oracle: nil, interval: 'WEEK', intervalCount: 6, maxCycles: 10, minCycles: 3, deliveryPrice: 5.50, nextBillingDate: Time.zone.today + 30.days) ⇒ Object
rubocop:disable Metrics/MethodLength.
- .create_v2(customer_id:, customerPaymentMethodId:, oracle: nil) ⇒ Object
Instance Method Summary collapse
-
#initialize(id:, oracle: nil) ⇒ SubscriptionContract
constructor
A new instance of SubscriptionContract.
- #reload ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(id:, oracle: nil) ⇒ SubscriptionContract
Returns a new instance of SubscriptionContract.
92 93 94 95 |
# File 'lib/shopify_oracle/accessor/subscription_contract.rb', line 92 def initialize(id:, oracle: nil) super @contract = @object end |
Instance Attribute Details
#contract ⇒ Object (readonly)
Returns the value of attribute contract.
90 91 92 |
# File 'lib/shopify_oracle/accessor/subscription_contract.rb', line 90 def contract @contract end |
Class Method Details
.create(customer:, oracle: nil, interval: 'WEEK', intervalCount: 6, maxCycles: 10, minCycles: 3, deliveryPrice: 5.50, nextBillingDate: Time.zone.today + 30.days) ⇒ Object
rubocop:disable Metrics/MethodLength
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/shopify_oracle/accessor/subscription_contract.rb', line 24 def create( customer:, oracle: nil, interval: 'WEEK', intervalCount: 6, maxCycles: 10, minCycles: 3, deliveryPrice: 5.50, nextBillingDate: Time.zone.today + 30.days ) address = customer.default_address input = { contract: { billingPolicy: { interval:, intervalCount:, maxCycles:, minCycles: }, customAttributes: [ { key: 'key', value: 'value' } ], deliveryMethod: { shipping: { address: { address1: address.address1, address2: address.address2, city: address.city, company: address.company, firstName: address.first_name, lastName: address.last_name, phone: address.phone, provinceCode: address.region_code, zip: address.zip, countryCode: address.country_code }, shippingOption: { code: 'abc', description: 'description', presentmentTitle: 'title', title: 'title' } } }, deliveryPolicy: { interval:, intervalCount: }, deliveryPrice:, nextBillingDate:, note: 'note', status: 'ACTIVE' }, customerId: "gid://shopify/Customer/#{customer.ext_id}", nextBillingDate: Time.zone.today + 30.days, currencyCode: 'GBP' } ShopifyOracle.mutate(:create_subscription_contract, input:) end |
.create_v2(customer_id:, customerPaymentMethodId:, oracle: nil) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/shopify_oracle/accessor/subscription_contract.rb', line 9 def create_v2( customer_id:, customerPaymentMethodId:, oracle: nil ) customerId = customer_id.is_a?(Integer) ? "gid://shopify/Customer/#{customer_id}" : customer_id ShopifyOracle.mutate( :create_subscription_contract_v2, customerId:, customerPaymentMethodId: ) end |
Instance Method Details
#reload ⇒ Object
97 98 99 100 |
# File 'lib/shopify_oracle/accessor/subscription_contract.rb', line 97 def reload super @contract = @object end |