Class: Hookdeck::Resources::Bookmark

Inherits:
Base
  • Object
show all
Defined in:
lib/hookdeck/resources/bookmark.rb

Overview

Examples:

Create a new bookmark

client.bookmarks.create(
  label: "Product Update – Out of Stock",
  event_data_id: "evtreq_HlJhb39nsjIP0FDsU3SY0fo7",
  webhook_id: "web_UfM5ZY2wxLD6sLhDaKMcx5wp"
)

Trigger a bookmark

client.bookmarks.trigger('bkm_123')

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Hookdeck::Resources::Base

Instance Method Details

#create(params) ⇒ Hash

Creates a bookmark.

"label": "Product Update – Out of Stock",
"event_data_id": "evtreq_HlJhb39nsjIP0FDsU3SY0fo7",
"webhook_id": "web_UfM5ZY2wxLD6sLhDaKMcx5wp"

Parameters:

  • params (Hash)

    The parameters.

Returns:

  • (Hash)

    The bookmark.



37
38
39
# File 'lib/hookdeck/resources/bookmark.rb', line 37

def create(params)
  post('bookmarks', params)
end

#delete(id) ⇒ Object



64
65
66
67
# File 'lib/hookdeck/resources/bookmark.rb', line 64

def delete(id)
  validate_id!(id, 'bkm_')
  delete("bookmarks/#{id}")
end

#list(params = {}) ⇒ Object



16
17
18
# File 'lib/hookdeck/resources/bookmark.rb', line 16

def list(params = {})
  get('bookmarks', params)
end

#retrieve(id) ⇒ Hash

Retrieves a bookmark by ID.

Parameters:

  • id (String)

    The ID of the bookmark.

Returns:

  • (Hash)

    The bookmark.



24
25
26
27
# File 'lib/hookdeck/resources/bookmark.rb', line 24

def retrieve(id)
  validate_id!(id, 'bkm_')
  get("bookmarks/#{id}")
end

#trigger(id, params = {}) ⇒ Hash

This endpoint uses a bookmark to create events.

Parameters:

  • id (String)

    The ID of the bookmark.

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

    The parameters.

Returns:

  • (Hash)

    The bookmark.



59
60
61
62
# File 'lib/hookdeck/resources/bookmark.rb', line 59

def trigger(id, params = {})
  validate_id!(id, 'bkm_')
  post("bookmarks/#{id}/trigger", params)
end

#update(id, params) ⇒ Hash

Updates a bookmark.

"label": "Product Update – Out of Stock",
"event_data_id": "evtreq_HlJhb39nsjIP0FDsU3SY0fo7",
"webhook_id": "web_UfM5ZY2wxLD6sLhDaKMcx5wp"

Parameters:

  • id (String)

    The ID of the bookmark.

  • params (Hash)

    The parameters.

Returns:

  • (Hash)

    The bookmark.



50
51
52
53
# File 'lib/hookdeck/resources/bookmark.rb', line 50

def update(id, params)
  validate_id!(id, 'bkm_')
  put("bookmarks/#{id}", params)
end