Class: BeyondApi::PickupOptions

Inherits:
Base
  • Object
show all
Includes:
Utils
Defined in:
lib/beyond_api/resources/pickup_options.rb

Instance Attribute Summary

Attributes inherited from Base

#session

Instance Method Summary collapse

Methods included from Utils

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

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from BeyondApi::Base

Instance Method Details

#all(params = {}) ⇒ OpenStruct

A GET request is used to list all pickup options of the shop in a paged way.

$ curl 'https://api-shop.beyondshop.cloud/api/pickup-options' -i -X GET \
    -H 'Accept: application/hal+json' \
    -H 'Authorization: Bearer <Access token>'

Examples:

@pickup_options = session.pickup_options.all(size: 100, page: 0)

Parameters:

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :paginated (Boolean)
  • :size (Integer)

    the page size

  • :page (Integer)

    the page number

Returns:

  • (OpenStruct)


25
26
27
# File 'lib/beyond_api/resources/pickup_options.rb', line 25

def all(params = {})
  handle_all_request("/pickup-options", :pickup_options, params)
end

#create(body) ⇒ OpenStruct

A POST request is used to create a pickup option.

$ curl 'https://api-shop.beyondshop.cloud/api/pickup-options' -i -X POST \
    -H 'Content-Type: application/json' \
    -H 'Authorization: Bearer <Access token>' \
    -d '{
    "name" : "My little Cornershop - St.Ives",
    "description" : "We will send you an email when your items are ready for pickup. Please bring a copy of your order confirmation.",
    "taxClass" : "REGULAR",
    "freePickupValue" : {
      "currency" : "EUR",
      "amount" : 50
    },
    "fixedPrice" : {
      "taxModel" : "GROSS",
      "currency" : "EUR",
      "amount" : 1
    },
    "phoneNumberRequired" : true,
    "locationId" : "cb554eb6-2768-4491-afd2-6bcd0aec0937"
}'

Examples:

body = {
  name: "My little Cornershop - St.Ives",
  description: "We will send you an email when your items are ready for pickup. Please bring a copy of your order confirmation.",
  tax_class: "REGULAR",
  free_pickup_value: {
    currency: "EUR",
    amount: 50
  },
  fixed_price: {
    tax_model: "GROSS",
    currency: "EUR",
    amount: 1
  },
  phone_number_required: true,
  location_id: "cb554eb6-2768-4491-afd2-6bcd0aec0937"
}

@pickup_option = session.pickup_options.create(body)

Parameters:

  • body (Hash)

    the request body

Returns:

  • (OpenStruct)

Scopes:

  • shpz:c



78
79
80
81
82
# File 'lib/beyond_api/resources/pickup_options.rb', line 78

def create(body)
  response, status = BeyondApi::Request.post(@session, "/pickup-options", body)

  handle_response(response, status)
end

#delete(pickup_option_id) ⇒ Object

A DELETE request is used to delete a pickup option.

$ curl 'https://api-shop.beyondshop.cloud/api/pickup-options/d253a31b-3892-4196-ae16-c5d8d6b05791' -i -X DELETE

Examples:

session.pickup_options.delete("d253a31b-3892-4196-ae16-c5d8d6b05791")

Parameters:

  • pickup_option_id (String)

    the pickup option UUID

Returns:

  • true

Scopes:

  • shpz:d



98
99
100
101
102
# File 'lib/beyond_api/resources/pickup_options.rb', line 98

def delete(pickup_option_id)
  response, status = BeyondApi::Request.delete(@session, "/pickup-options/#{pickup_option_id}")

  handle_response(response, status, respond_with_true: true)
end

#find(pickup_option_id) ⇒ OpenStruct

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

$ curl 'https://api-shop.beyondshop.cloud/api/pickup-options/76302c10-761f-43c1-9d18-52ad16bd52e8' -i -X GET \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/hal+json' \
    -H 'Authorization: Bearer <Access token>'

Examples:

@pickup_option = session.pickup_options.find("76302c10-761f-43c1-9d18-52ad16bd52e8")

Parameters:

  • pickup_option_id (String)

    the pickup option UUID

Returns:

  • (OpenStruct)

Scopes:

  • shpz:r



121
122
123
124
125
# File 'lib/beyond_api/resources/pickup_options.rb', line 121

def find(pickup_option_id)
  response, status = BeyondApi::Request.get(@session, "/pickup-options/#{pickup_option_id}")

  handle_response(response, status)
end

#sort(pickup_option_ids) ⇒ OpenStruct

A PUT request is used to sort the pickup options. This is done by passing the self-links of the pickup options in the desired order. The request must contain URIs for all pickup options of the given page.

$ curl 'https://api-shop.beyondshop.cloud/api/pickup-options' -i -X PUT \
    -H 'Content-Type: text/uri-list' \
    -H 'Authorization: Bearer <Access token>' \
    -d 'https://api-shop.beyondshop.cloud/api/pickup-options/bff3673f-91c1-4e09-a8ab-562a3a553fac
        https://api-shop.beyondshop.cloud/api/pickup-options/7b4d36fc-ac0f-44a3-8655-f2bd05c2a42d
        https://api-shop.beyondshop.cloud/api/pickup-options/630b63ee-c7d8-4953-9b7c-c874fd795154'

Examples:

pickup_option_ids = [
  "bff3673f-91c1-4e09-a8ab-562a3a553fac",
  "7b4d36fc-ac0f-44a3-8655-f2bd05c2a42d",
  "630b63ee-c7d8-4953-9b7c-c874fd795154"
]

session.pickup_options.sort(pickup_option_ids)

Parameters:

  • pickup_option_ids (Array)

    the pickup option UUIDs

Returns:

  • (OpenStruct)

Scopes:

  • shpz:u



152
153
154
155
156
157
# File 'lib/beyond_api/resources/pickup_options.rb', line 152

def sort(pickup_option_ids)
  body = pickup_option_ids.map { |id| "#{@session.api_url}/pickup-options/#{id}" }
  response, status = BeyondApi::Request.put(@session, "/pickup-options", body)

  handle_response(response, status, respond_with_true: true)
end

#update(pickup_option_id, body) ⇒ OpenStruct

A PUT request is used to update a pickup option.

$ curl 'https://api-shop.beyondshop.cloud/api/pickup-options/5765b837-db5b-49a9-a659-68d00376e42a' -i -X PUT \
    -H 'Content-Type: application/json' \
    -H 'Accept: application/hal+json' \
    -H 'Authorization: Bearer <Access token>' \
    -d '{
    "name" : "New name",
    "description" : "We will send you an email when your items are ready for pickup. Please bring a copy of your order confirmation.",
    "taxClass" : "REGULAR",
    "freePickupValue" : {
      "currency" : "EUR",
      "amount" : 50
    },
    "fixedPrice" : {
      "taxModel" : "GROSS",
      "currency" : "EUR",
      "amount" : 1
    },
    "phoneNumberRequired" : true,
    "locationId" : "c9179393-abcc-450a-8cf4-875b39647ab6"
}'

Examples:

body = {
  name: "New name",
  description: "We will send you an email when your items are ready for pickup. Please bring a copy of your order confirmation.",
  tax_class: "REGULAR",
  free_pickup_value: {
    currency: "EUR",
    amount: 50
  },
  fixed_price: {
    tax_model: "GROSS",
    currency: "EUR",
    amount: 1
  },
  phone_number_required: true,
  location_id: "c9179393-abcc-450a-8cf4-875b39647ab6"
}

@pickup_option = session.pickup_options.update("5765b837-db5b-49a9-a659-68d00376e42a", body)

Parameters:

  • pickup_option_id (String)

    the pickup option UUID

  • body (Hash)

    the request body

Returns:

  • (OpenStruct)

Scopes:

  • shpz:u



210
211
212
213
214
# File 'lib/beyond_api/resources/pickup_options.rb', line 210

def update(pickup_option_id, body)
  response, status = BeyondApi::Request.put(@session, "/pickup-options/#{pickup_option_id}", body)

  handle_response(response, status)
end