Module: BeyondApi::ProductVideos

Included in:
Products
Defined in:
lib/beyond_api/resources/products/videos.rb

Instance Method Summary collapse

Instance Method Details

#add_video(product_id, body) ⇒ OpenStruct

A POST request is used to create a video and add it to a product.

$ curl 'https://api-shop.beyondshop.cloud/api/products/f7716244-568c-4536-bc25-317030f83395/videos' -i -X POST \
    -H 'Content-Type: application/hal+json' \
    -H 'Accept: application/hal+json' \
    -H 'Authorization: Bearer <Access token>' \
    -d '{
    "type" : "VIMEO",
    "source" : "https://vimeo.com/7265982"
}'

Examples:

body = {
  "type" => "VIMEO",
  "source" => "https://vimeo.com/7265982"
}
@video = session.products.add_video("f7716244-568c-4536-bc25-317030f83395", body)

Parameters:

  • product_id (String)

    the product UUID

  • body (Hash)

    the request body

Returns:

  • (OpenStruct)

Scopes:

  • prod:u



33
34
35
36
37
# File 'lib/beyond_api/resources/products/videos.rb', line 33

def add_video(product_id, body)
  response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/videos", body)

  handle_response(response, status)
end

#delete_video(product_id, video_id) ⇒ true

A DELETE request is used to delete a product video

$ curl 'https://api-shop.beyondshop.cloud/api/products/1cc9ef5e-62b1-43c7-8745-f4aa8be79934/videos/60869f60-1a4b-4013-b86c-00a2ab9ddc2c' -i -X DELETE \
    -H 'Content-Type: application/hal+json' \
    -H 'Accept: application/hal+json' \
    -H 'Authorization: Bearer <Access token>'

Examples:

session.products.delete_video("1cc9ef5e-62b1-43c7-8745-f4aa8be79934", "60869f60-1a4b-4013-b86c-00a2ab9ddc2c")

Parameters:

  • product_id (String)

    the product UUID

  • video_id (String)

    the video UUID

Returns:

  • (true)

Scopes:

  • prod:u



57
58
59
60
61
# File 'lib/beyond_api/resources/products/videos.rb', line 57

def delete_video(product_id, video_id)
  response, status = BeyondApi::Request.delete(@session, "/products/#{product_id}/videos/#{video_id}")

  handle_response(response, status, respond_with_true: true)
end

#update_video(product_id, video_id, body) ⇒ OpenStruct

A PUT request is used to update a video.

$ curl 'https://api-shop.beyondshop.cloud/api/products/9d33da61-1f60-4ad3-9de0-2f1dc0910ebb/videos/ef51af21-5381-4ccb-a107-8bfa574d3556' -i -X PUT \
    -H 'Content-Type: application/hal+json' \
    -H 'Accept: application/hal+json' \
    -H 'Authorization: Bearer <Access token>' \
    -d '{
    "type" : "VIMEO",
    "source" : "https://vimeo.com/7265982"
}'

Examples:

body = {
  "type" => "VIMEO",
  "source" => "https://vimeo.com/7265982"
}
@video = session.products.update_video("9d33da61-1f60-4ad3-9de0-2f1dc0910ebb", "ef51af21-5381-4ccb-a107-8bfa574d3556", body)

Parameters:

  • product_id (String)

    the product UUID

  • video_id (String)

    the video UUID

  • body (Hash)

    the request body

Returns:

  • (OpenStruct)

Scopes:

  • prod:u



90
91
92
93
94
# File 'lib/beyond_api/resources/products/videos.rb', line 90

def update_video(product_id, video_id, body)
  response, status = BeyondApi::Request.put(@session, "/products/#{product_id}/videos/#{video_id}", body)

  handle_response(response, status)
end

#video(product_id, video_id) ⇒ OpenStruct

A GET request is used to retrieve a single video of a product.

$ curl 'https://api-shop.beyondshop.cloud/api/products/94c3baf9-1390-4bf8-a6c1-fb234533fa14/videos/ada27b8c-ddf0-489a-9143-5bec938c1e17' -i -X GET \
    -H 'Content-Type: application/hal+json' \
    -H 'Accept: application/hal+json' \
    -H 'Authorization: Bearer <Access token>'

Examples:

@video = session.products.video("94c3baf9-1390-4bf8-a6c1-fb234533fa14", "ada27b8c-ddf0-489a-9143-5bec938c1e17")

Parameters:

  • product_id (String)

    the product UUID

  • video_id (String)

    the video UUID

Returns:

  • (OpenStruct)

Scopes:

  • prod:r



114
115
116
117
118
# File 'lib/beyond_api/resources/products/videos.rb', line 114

def video(product_id, video_id)
  response, status = BeyondApi::Request.get(@session, "/products/#{product_id}/videos/#{video_id}")

  handle_response(response, status)
end

#videos(product_id, params = {}) ⇒ OpenStruct

A GET request is used to retrieve the videos of a product.

$ curl 'https://api-shop.beyondshop.cloud/api/products/04c6ad65-465d-405e-a428-f73349104b65/videos' -i -X GET \
    -H 'Content-Type: application/hal+json' \
    -H 'Accept: application/hal+json' \
    -H 'Authorization: Bearer <Access token>'

Examples:

@videos = session.products.videos("04c6ad65-465d-405e-a428-f73349104b65", size: 100, page: 0)

Parameters:

  • product_id (String)

    the product UUID

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

    a customizable set of options

Options Hash (params):

  • :size (Integer)

    the page size

  • :page (Integer)

    the page number

Returns:

  • (OpenStruct)

Scopes:

  • prod:r



139
140
141
142
143
144
145
# File 'lib/beyond_api/resources/products/videos.rb', line 139

def videos(product_id, params = {})
  response, status = BeyondApi::Request.get(@session,
                                            "/products/#{product_id}/videos",
                                            params)

  handle_response(response, status)
end