Class: SPOSClient
- Inherits:
-
Object
- Object
- SPOSClient
- Defined in:
- lib/spos-client.rb
Instance Attribute Summary collapse
-
#Adcodes ⇒ Object
readonly
Returns the value of attribute Adcodes.
-
#Addresses ⇒ Object
readonly
Returns the value of attribute Addresses.
-
#Affiliates ⇒ Object
readonly
Returns the value of attribute Affiliates.
-
#AttributeGroups ⇒ Object
readonly
Returns the value of attribute AttributeGroups.
-
#Attributes ⇒ Object
readonly
Returns the value of attribute Attributes.
-
#BlogCategories ⇒ Object
readonly
Returns the value of attribute BlogCategories.
-
#BlogPosts ⇒ Object
readonly
Returns the value of attribute BlogPosts.
-
#Blogs ⇒ Object
readonly
Returns the value of attribute Blogs.
-
#CartItems ⇒ Object
readonly
Returns the value of attribute CartItems.
-
#Carts ⇒ Object
readonly
Returns the value of attribute Carts.
-
#Categories ⇒ Object
readonly
Returns the value of attribute Categories.
-
#CouponCodes ⇒ Object
readonly
Returns the value of attribute CouponCodes.
-
#CreditCards ⇒ Object
readonly
Returns the value of attribute CreditCards.
-
#CustomerPaymentMethods ⇒ Object
readonly
Returns the value of attribute CustomerPaymentMethods.
-
#Customers ⇒ Object
readonly
Returns the value of attribute Customers.
-
#CustomerTypes ⇒ Object
readonly
Returns the value of attribute CustomerTypes.
-
#CustomFields ⇒ Object
readonly
Returns the value of attribute CustomFields.
-
#CustomFieldValues ⇒ Object
readonly
Returns the value of attribute CustomFieldValues.
-
#CustomShippingMethods ⇒ Object
readonly
Returns the value of attribute CustomShippingMethods.
-
#DiscountMethods ⇒ Object
readonly
Returns the value of attribute DiscountMethods.
-
#DiscountRules ⇒ Object
readonly
Returns the value of attribute DiscountRules.
-
#Drips ⇒ Object
readonly
Returns the value of attribute Drips.
-
#EmailTemplates ⇒ Object
readonly
Returns the value of attribute EmailTemplates.
-
#GiftCertificates ⇒ Object
readonly
Returns the value of attribute GiftCertificates.
-
#GiftCertificateTransactions ⇒ Object
readonly
Returns the value of attribute GiftCertificateTransactions.
-
#Inventory ⇒ Object
readonly
Returns the value of attribute Inventory.
-
#Links ⇒ Object
readonly
Returns the value of attribute Links.
-
#MailingLists ⇒ Object
readonly
Returns the value of attribute MailingLists.
-
#Manufacturers ⇒ Object
readonly
Returns the value of attribute Manufacturers.
-
#OrderAddresses ⇒ Object
readonly
Returns the value of attribute OrderAddresses.
-
#OrderItems ⇒ Object
readonly
Returns the value of attribute OrderItems.
-
#OrderPayments ⇒ Object
readonly
Returns the value of attribute OrderPayments.
-
#Orders ⇒ Object
readonly
Returns the value of attribute Orders.
-
#OrderShipments ⇒ Object
readonly
Returns the value of attribute OrderShipments.
-
#OrderStatuses ⇒ Object
readonly
Returns the value of attribute OrderStatuses.
-
#Pages ⇒ Object
readonly
Returns the value of attribute Pages.
-
#PaymentMethods ⇒ Object
readonly
Returns the value of attribute PaymentMethods.
-
#ProductLists ⇒ Object
readonly
Returns the value of attribute ProductLists.
-
#ProductPictures ⇒ Object
readonly
Returns the value of attribute ProductPictures.
-
#ProductReviews ⇒ Object
readonly
Returns the value of attribute ProductReviews.
-
#Products ⇒ Object
readonly
Returns the value of attribute Products.
-
#ProductStatuses ⇒ Object
readonly
Returns the value of attribute ProductStatuses.
-
#ProductVariants ⇒ Object
readonly
Returns the value of attribute ProductVariants.
-
#Profiles ⇒ Object
readonly
Returns the value of attribute Profiles.
-
#Quotes ⇒ Object
readonly
Returns the value of attribute Quotes.
-
#Regions ⇒ Object
readonly
Returns the value of attribute Regions.
-
#Sessions ⇒ Object
readonly
Returns the value of attribute Sessions.
-
#ShippingProviders ⇒ Object
readonly
Returns the value of attribute ShippingProviders.
-
#ShippingRateAdjustments ⇒ Object
readonly
Returns the value of attribute ShippingRateAdjustments.
-
#Stores ⇒ Object
readonly
Returns the value of attribute Stores.
-
#Subscriptions ⇒ Object
readonly
Returns the value of attribute Subscriptions.
-
#TaxRates ⇒ Object
readonly
Returns the value of attribute TaxRates.
-
#UrlRedirects ⇒ Object
readonly
Returns the value of attribute UrlRedirects.
-
#Users ⇒ Object
readonly
Returns the value of attribute Users.
-
#VariantGroups ⇒ Object
readonly
Returns the value of attribute VariantGroups.
-
#VariantInventory ⇒ Object
readonly
Returns the value of attribute VariantInventory.
-
#Warehouses ⇒ Object
readonly
Returns the value of attribute Warehouses.
-
#Webhooks ⇒ Object
readonly
Returns the value of attribute Webhooks.
-
#Wishlists ⇒ Object
readonly
Returns the value of attribute Wishlists.
Instance Method Summary collapse
-
#initialize(domain, token) ⇒ SPOSClient
constructor
A new instance of SPOSClient.
- #parse_query(opts) ⇒ Object
- #request(path, body = nil, opts = nil, method = nil) ⇒ Object
Constructor Details
#initialize(domain, token) ⇒ SPOSClient
Returns a new instance of SPOSClient.
13 14 15 16 17 18 19 20 21 22 23 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 |
# File 'lib/spos-client.rb', line 13 def initialize(domain, token) @domain = domain @token = token @Adcodes = Resource.new "adcodes", self @Addresses = Resource.new "addresses", self @Affiliates = Resource.new "affiliates", self @AttributeGroups = Resource.new "attribute_groups", self @Attributes = Resource.new "attributes", self @BlogCategories = Resource.new "blog_categories", self @BlogPosts = Resource.new "blog_posts", self @Blogs = Resource.new "blogs", self @CartItems = Resource.new "cart_items", self @Carts = Resource.new "carts", self @Categories = Resource.new "categories", self @CouponCodes = Resource.new "coupon_codes", self @CreditCards = Resource.new "credit_cards", self @CustomFieldValues = Resource.new "custom_field_values", self @CustomFields = Resource.new "custom_fields", self @CustomShippingMethods = Resource.new "custom_shipping_methods", self @CustomerPaymentMethods = Resource.new "customer_payment_methods", self @CustomerTypes = Resource.new "customer_types", self @Customers = Resource.new "customers", self @DiscountMethods = Resource.new "discount_methods", self @DiscountRules = Resource.new "discount_rules", self @Drips = Resource.new "drips", self @EmailTemplates = EmailTemplateResource.new "email_templates", self @GiftCertificateTransactions = Resource.new "gift_certificate_transactions", self @GiftCertificates = Resource.new "gift_certificates", self @Inventory = Resource.new "inventory", self @Links = Resource.new "links", self @MailingLists = Resource.new "mailing_lists", self @Manufacturers = Resource.new "manufacturers", self @OrderAddresses = Resource.new "order_addresses", self @OrderItems = Resource.new "order_items", self @OrderPayments = Resource.new "order_payments", self @OrderShipments = Resource.new "order_shipments", self @OrderStatuses = Resource.new "order_statuses", self @Orders = OrderResource.new "orders", self @Pages = Resource.new "pages", self @PaymentMethods = Resource.new "payment_methods", self @ProductLists = Resource.new "product_lists", self @ProductPictures = Resource.new "product_pictures", self @ProductReviews = Resource.new "product_reviews", self @ProductStatuses = Resource.new "product_statuses", self @ProductVariants = Resource.new "product_variants", self @Products = Resource.new "products", self @Profiles = Resource.new "profiles", self @Quotes = Resource.new "quotes", self @Regions = Resource.new "regions", self @Sessions = Resource.new "sessions", self @ShippingProviders = Resource.new "shipping_providers", self @ShippingRateAdjustments = Resource.new "shipping_rate_adjustments", self @Stores = Resource.new "stores", self @Subscriptions = Resource.new "subscriptions", self @TaxRates = Resource.new "tax_rates", self @UrlRedirects = Resource.new "url_redirects", self @Users = Resource.new "users", self @VariantGroups = Resource.new "variant_groups", self @VariantInventory = Resource.new "variant_inventory", self @Warehouses = Resource.new "warehouses", self @Webhooks = Resource.new "webhooks", self @Wishlists = Resource.new "wishlists", self end |
Instance Attribute Details
#Adcodes ⇒ Object (readonly)
Returns the value of attribute Adcodes.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Adcodes @Adcodes end |
#Addresses ⇒ Object (readonly)
Returns the value of attribute Addresses.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Addresses @Addresses end |
#Affiliates ⇒ Object (readonly)
Returns the value of attribute Affiliates.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Affiliates @Affiliates end |
#AttributeGroups ⇒ Object (readonly)
Returns the value of attribute AttributeGroups.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def AttributeGroups @AttributeGroups end |
#Attributes ⇒ Object (readonly)
Returns the value of attribute Attributes.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Attributes @Attributes end |
#BlogCategories ⇒ Object (readonly)
Returns the value of attribute BlogCategories.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def BlogCategories @BlogCategories end |
#BlogPosts ⇒ Object (readonly)
Returns the value of attribute BlogPosts.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def BlogPosts @BlogPosts end |
#Blogs ⇒ Object (readonly)
Returns the value of attribute Blogs.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Blogs @Blogs end |
#CartItems ⇒ Object (readonly)
Returns the value of attribute CartItems.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def CartItems @CartItems end |
#Carts ⇒ Object (readonly)
Returns the value of attribute Carts.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Carts @Carts end |
#Categories ⇒ Object (readonly)
Returns the value of attribute Categories.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Categories @Categories end |
#CouponCodes ⇒ Object (readonly)
Returns the value of attribute CouponCodes.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def CouponCodes @CouponCodes end |
#CreditCards ⇒ Object (readonly)
Returns the value of attribute CreditCards.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def CreditCards @CreditCards end |
#CustomerPaymentMethods ⇒ Object (readonly)
Returns the value of attribute CustomerPaymentMethods.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def CustomerPaymentMethods @CustomerPaymentMethods end |
#Customers ⇒ Object (readonly)
Returns the value of attribute Customers.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Customers @Customers end |
#CustomerTypes ⇒ Object (readonly)
Returns the value of attribute CustomerTypes.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def CustomerTypes @CustomerTypes end |
#CustomFields ⇒ Object (readonly)
Returns the value of attribute CustomFields.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def CustomFields @CustomFields end |
#CustomFieldValues ⇒ Object (readonly)
Returns the value of attribute CustomFieldValues.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def CustomFieldValues @CustomFieldValues end |
#CustomShippingMethods ⇒ Object (readonly)
Returns the value of attribute CustomShippingMethods.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def CustomShippingMethods @CustomShippingMethods end |
#DiscountMethods ⇒ Object (readonly)
Returns the value of attribute DiscountMethods.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def DiscountMethods @DiscountMethods end |
#DiscountRules ⇒ Object (readonly)
Returns the value of attribute DiscountRules.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def DiscountRules @DiscountRules end |
#Drips ⇒ Object (readonly)
Returns the value of attribute Drips.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Drips @Drips end |
#EmailTemplates ⇒ Object (readonly)
Returns the value of attribute EmailTemplates.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def EmailTemplates @EmailTemplates end |
#GiftCertificates ⇒ Object (readonly)
Returns the value of attribute GiftCertificates.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def GiftCertificates @GiftCertificates end |
#GiftCertificateTransactions ⇒ Object (readonly)
Returns the value of attribute GiftCertificateTransactions.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def GiftCertificateTransactions @GiftCertificateTransactions end |
#Inventory ⇒ Object (readonly)
Returns the value of attribute Inventory.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Inventory @Inventory end |
#Links ⇒ Object (readonly)
Returns the value of attribute Links.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Links @Links end |
#MailingLists ⇒ Object (readonly)
Returns the value of attribute MailingLists.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def MailingLists @MailingLists end |
#Manufacturers ⇒ Object (readonly)
Returns the value of attribute Manufacturers.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Manufacturers @Manufacturers end |
#OrderAddresses ⇒ Object (readonly)
Returns the value of attribute OrderAddresses.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def OrderAddresses @OrderAddresses end |
#OrderItems ⇒ Object (readonly)
Returns the value of attribute OrderItems.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def OrderItems @OrderItems end |
#OrderPayments ⇒ Object (readonly)
Returns the value of attribute OrderPayments.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def OrderPayments @OrderPayments end |
#Orders ⇒ Object (readonly)
Returns the value of attribute Orders.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Orders @Orders end |
#OrderShipments ⇒ Object (readonly)
Returns the value of attribute OrderShipments.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def OrderShipments @OrderShipments end |
#OrderStatuses ⇒ Object (readonly)
Returns the value of attribute OrderStatuses.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def OrderStatuses @OrderStatuses end |
#Pages ⇒ Object (readonly)
Returns the value of attribute Pages.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Pages @Pages end |
#PaymentMethods ⇒ Object (readonly)
Returns the value of attribute PaymentMethods.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def PaymentMethods @PaymentMethods end |
#ProductLists ⇒ Object (readonly)
Returns the value of attribute ProductLists.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def ProductLists @ProductLists end |
#ProductPictures ⇒ Object (readonly)
Returns the value of attribute ProductPictures.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def ProductPictures @ProductPictures end |
#ProductReviews ⇒ Object (readonly)
Returns the value of attribute ProductReviews.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def ProductReviews @ProductReviews end |
#Products ⇒ Object (readonly)
Returns the value of attribute Products.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Products @Products end |
#ProductStatuses ⇒ Object (readonly)
Returns the value of attribute ProductStatuses.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def ProductStatuses @ProductStatuses end |
#ProductVariants ⇒ Object (readonly)
Returns the value of attribute ProductVariants.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def ProductVariants @ProductVariants end |
#Profiles ⇒ Object (readonly)
Returns the value of attribute Profiles.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Profiles @Profiles end |
#Quotes ⇒ Object (readonly)
Returns the value of attribute Quotes.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Quotes @Quotes end |
#Regions ⇒ Object (readonly)
Returns the value of attribute Regions.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Regions @Regions end |
#Sessions ⇒ Object (readonly)
Returns the value of attribute Sessions.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Sessions @Sessions end |
#ShippingProviders ⇒ Object (readonly)
Returns the value of attribute ShippingProviders.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def ShippingProviders @ShippingProviders end |
#ShippingRateAdjustments ⇒ Object (readonly)
Returns the value of attribute ShippingRateAdjustments.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def ShippingRateAdjustments @ShippingRateAdjustments end |
#Stores ⇒ Object (readonly)
Returns the value of attribute Stores.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Stores @Stores end |
#Subscriptions ⇒ Object (readonly)
Returns the value of attribute Subscriptions.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Subscriptions @Subscriptions end |
#TaxRates ⇒ Object (readonly)
Returns the value of attribute TaxRates.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def TaxRates @TaxRates end |
#UrlRedirects ⇒ Object (readonly)
Returns the value of attribute UrlRedirects.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def UrlRedirects @UrlRedirects end |
#Users ⇒ Object (readonly)
Returns the value of attribute Users.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Users @Users end |
#VariantGroups ⇒ Object (readonly)
Returns the value of attribute VariantGroups.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def VariantGroups @VariantGroups end |
#VariantInventory ⇒ Object (readonly)
Returns the value of attribute VariantInventory.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def VariantInventory @VariantInventory end |
#Warehouses ⇒ Object (readonly)
Returns the value of attribute Warehouses.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Warehouses @Warehouses end |
#Webhooks ⇒ Object (readonly)
Returns the value of attribute Webhooks.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Webhooks @Webhooks end |
#Wishlists ⇒ Object (readonly)
Returns the value of attribute Wishlists.
11 12 13 |
# File 'lib/spos-client.rb', line 11 def Wishlists @Wishlists end |
Instance Method Details
#parse_query(opts) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/spos-client.rb', line 78 def parse_query(opts) if(opts.nil?) return "" end queries = [] opts.each do |key, value| unless(value.nil?) queries << "#{key}=#{value}" end end "?#{queries.join('&')}" end |
#request(path, body = nil, opts = nil, method = nil) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/spos-client.rb', line 94 def request(path, body = nil, opts = nil, method = nil) original_body = body query = self.parse_query(opts) uri = URI.parse("https://#{@domain}/api/v1/#{path}#{query}") http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true if(body.nil?) request = Net::HTTP::Get.new(uri.request_uri) else if(body.has_key?("id")) request = Net::HTTP::Put.new(uri.request_uri) else case method when "GET" request = Net::HTTP::Get.new(uri.request_uri) when "PUT" request = Net::HTTP::Put.new(uri.request_uri) else request = Net::HTTP::Post.new(uri.request_uri) end end request.add_field('Content-Type', 'application/json') request.body = body.to_json end request['X-AC-Auth-Token'] = @token response = http.request(request) if(response.nil? || response.body.nil?) body = nil else body = JSON.parse(JSON.parse(response.body).to_json, object_class: OpenStruct) end if !body.nil? && body.status_code === 429 time = Time.now.time_until(Time.parse(response['Retry-After'])) sleeptime = (time/1000) if(sleeptime > 0) sleep sleeptime end body = request(path, original_body, opts, method) end body end |