Class: BeyondApi::Shop

Inherits:
Base
  • Object
show all
Includes:
ShopAddress, ShopAttributes, ShopImages, ShopLegals, ShopLocations, Utils
Defined in:
lib/beyond_api/resources/shop.rb

Instance Attribute Summary

Attributes inherited from Base

#session

Instance Method Summary collapse

Methods included from Utils

#handle_all_request, #handle_error, #handle_response, #sanitize_key, #sanitize_response, #to_object_struct

Methods included from ShopLocations

#create_location, #delete_location, #location, #locations, #update_location

Methods included from ShopLegals

#legal_content, #legal_contents, #legal_details, #update_legal_content, #update_legal_details

Methods included from ShopImages

#create_image, #delete_image, #image, #images, #search_images_by_label, #upload_image

Methods included from ShopAttributes

#attribute, #attributes, #create_attribute, #delete_attribute, #update_attribute

Methods included from ShopAddress

#address, #update_address

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from BeyondApi::Base

Instance Method Details

#currentOpenStruct

A GET request is used to retrieve the details of a shop.

$ curl 'https://api-shop.beyondshop.cloud/api/shop' -i -X GET \
    -H 'Accept: application/hal+json'

Examples:

session.shop.current

Returns:

  • (OpenStruct)

31
32
33
34
35
# File 'lib/beyond_api/resources/shop.rb', line 31

def current
  response, status = BeyondApi::Request.get(@session, "/shop")

  handle_response(response, status)
end

#update(body) ⇒ OpenStruct

A PATCH request is used to change attributes of a shop.

$ curl 'https://api-shop.beyondshop.cloud/api/shop' -i -X PATCH \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/hal+json' \
    -H 'Authorization: Bearer <Access token>' \
    -d '{
  "name" : "anotherName",
  "primaryHostname" : "cornershop.amazingdiscounts.xyz",
  "fallbackHostname" : "cornershop.beyondshop.cloud",
  "tax" : {
    "taxModel" : "GROSS",
    "vatExempted" : false
  },
  "currencies" : [ "EUR", "USD", "GBP" ],
  "defaultCurrency" : "USD",
  "locales" : [ "en-GB", "de-DE" ],
  "defaultLocale" : "en-GB",
  "closedByMerchant" : false
}'

Examples:

body = {
  "name" => "anotherName",
  "primary_hostname" => "cornershop.amazingdiscounts.xyz",
  "fallback_hostname" => "cornershop.beyondshop.cloud",
  "tax" => {
    "taxModel" => "GROSS",
    "vatExempted" => false
  },
  "currencies" => [ "EUR", "USD", "GBP" ],
  "default_currency" => "USD",
  "locales" => [ "en-GB", "de-DE" ],
  "default_locale" => "en-GB",
  "closed_by_merchant" => false
}

session.shop.update(body)

Parameters:

  • body (Hash)

    the request body

Returns:

  • (OpenStruct)

Scopes:

  • shop:u


83
84
85
86
87
# File 'lib/beyond_api/resources/shop.rb', line 83

def update(body)
  response, status = BeyondApi::Request.patch(@session, "/shop",  body)

  handle_response(response, status)
end