Class: BeyondApi::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/beyond_api/session.rb

Defined Under Namespace

Classes: InvalidUriProtocolError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_url:, access_token: nil, refresh_token: nil) ⇒ Session

Returns a new instance of Session.



34
35
36
37
38
39
40
41
42
# File 'lib/beyond_api/session.rb', line 34

def initialize(api_url:, access_token: nil, refresh_token: nil)
  raise InvalidUriProtocolError, "Invalid URI protocol" unless api_url.start_with? "https://"

  uri = URI.parse(api_url)

  @api_url = "#{uri.scheme}://#{uri.host}/api"
  @access_token = access_token
  @refresh_token = refresh_token
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



32
33
34
# File 'lib/beyond_api/session.rb', line 32

def access_token
  @access_token
end

#api_urlObject (readonly)

Returns the value of attribute api_url.



31
32
33
# File 'lib/beyond_api/session.rb', line 31

def api_url
  @api_url
end

#refresh_tokenObject

Returns the value of attribute refresh_token.



32
33
34
# File 'lib/beyond_api/session.rb', line 32

def refresh_token
  @refresh_token
end

Instance Method Details

#cartsObject



44
45
46
# File 'lib/beyond_api/session.rb', line 44

def carts
  BeyondApi::Carts.new(self)
end

#categoriesObject



52
53
54
# File 'lib/beyond_api/session.rb', line 52

def categories
  BeyondApi::Categories.new(self)
end

#categories_viewObject



48
49
50
# File 'lib/beyond_api/session.rb', line 48

def categories_view
  BeyondApi::CategoriesView.new(self)
end

#checkout_settingsObject



56
57
58
# File 'lib/beyond_api/session.rb', line 56

def checkout_settings
  BeyondApi::CheckoutSettings.new(self)
end

#customersObject



60
61
62
# File 'lib/beyond_api/session.rb', line 60

def customers
  BeyondApi::Customers.new(self)
end

#newsletter_targetObject



64
65
66
# File 'lib/beyond_api/session.rb', line 64

def newsletter_target
  BeyondApi::NewsletterTarget.new(self)
end

#order_settingsObject



68
69
70
# File 'lib/beyond_api/session.rb', line 68

def order_settings
  BeyondApi::OrderSettings.new(self)
end

#ordersObject



72
73
74
# File 'lib/beyond_api/session.rb', line 72

def orders
  BeyondApi::Orders.new(self)
end

#payment_method_definitionsObject



76
77
78
# File 'lib/beyond_api/session.rb', line 76

def payment_method_definitions
  BeyondApi::PaymentMethodDefinitions.new(self)
end

#payment_methodsObject



80
81
82
# File 'lib/beyond_api/session.rb', line 80

def payment_methods
  BeyondApi::PaymentMethods.new(self)
end

#pickup_optionsObject



84
85
86
# File 'lib/beyond_api/session.rb', line 84

def pickup_options
  BeyondApi::PickupOptions.new(self)
end

#product_attribute_definitionsObject



88
89
90
# File 'lib/beyond_api/session.rb', line 88

def product_attribute_definitions
  BeyondApi::ProductAttributeDefinitions.new(self)
end

#productsObject



96
97
98
# File 'lib/beyond_api/session.rb', line 96

def products
  BeyondApi::Products.new(self)
end

#products_viewObject



92
93
94
# File 'lib/beyond_api/session.rb', line 92

def products_view
  BeyondApi::ProductsView.new(self)
end

#script_tagsObject



100
101
102
# File 'lib/beyond_api/session.rb', line 100

def script_tags
  BeyondApi::ScriptTags.new(self)
end

#shipping_zonesObject



104
105
106
# File 'lib/beyond_api/session.rb', line 104

def shipping_zones
  BeyondApi::ShippingZones.new(self)
end

#shopObject



108
109
110
# File 'lib/beyond_api/session.rb', line 108

def shop
  BeyondApi::Shop.new(self)
end

#signersObject



112
113
114
# File 'lib/beyond_api/session.rb', line 112

def signers
  BeyondApi::Signers.new(self)
end

#tokenObject



116
117
118
# File 'lib/beyond_api/session.rb', line 116

def token
  BeyondApi::Token.new(self)
end

#usersObject



120
121
122
# File 'lib/beyond_api/session.rb', line 120

def users
  BeyondApi::Users.new(self)
end

#variationsObject



124
125
126
# File 'lib/beyond_api/session.rb', line 124

def variations
  BeyondApi::Variations.new(self)
end

#webhook_subscriptionsObject



128
129
130
# File 'lib/beyond_api/session.rb', line 128

def webhook_subscriptions
  BeyondApi::WebhookSubscriptions.new(self)
end