Class: SeismicAPI::Teamsites

Inherits:
Object
  • Object
show all
Defined in:
lib/seismic_api/teamsites.rb

Overview

Client for all endpoints related to teamsites

Examples:

find all teamsites

SeismicAPI::Teamsites.new(oauth_token: "token").all

add folder to teamsite

SeismicAPI::Teamsites.new(oauth_token: "token")
  .add_folder(teamsiteId: "1", name: "My Folder")

Defined Under Namespace

Classes: AllTestResponse

Instance Method Summary collapse

Constructor Details

#initialize(oauth_token:) ⇒ self

Initialize teamsites client

Parameters:

  • oauth_token (String)

    valid oauth token


18
19
20
21
# File 'lib/seismic_api/teamsites.rb', line 18

def initialize(oauth_token:)
  @oauth_token = oauth_token
  @base_url = SeismicAPI.config.base_url + "/teamsites"
end

Instance Method Details

#add_folder(teamsiteId:, name:, parentFolderId: "root", **args) ⇒ SeismicAPI::Response

Create a folder in the teamsite

Parameters:

  • teamsiteId (String)

    ID of teamsite

  • name (String)

    name of folder

  • parentFolderId (String) (defaults to: "root")

    ID of parent folder (it not supplied, it goes into the root directory for that teamsite)

  • args (Hash)

    a customizable set of options

Options Hash (**args):

  • :externalId (String)

    ID in external system

  • :externalConnectionId (String)

    ID of external system

Returns:


52
53
54
55
56
57
# File 'lib/seismic_api/teamsites.rb', line 52

def add_folder(teamsiteId:, name:, parentFolderId: "root", **args)
  request.post(
    "#{teamsites_url}/#{teamsiteId}/folders",
    body: { name: name, parentFolderId: parentFolderId, **args }
  )
end

#add_url(teamsiteId:, name:, url:, **args) ⇒ SeismicAPI::Response

Add a url as content

Parameters:

  • teamsiteId (String)

    ID of teamsite

  • name (String)

    name to be displayed on the URL content card

  • url (Hash)

    Object representing URL to be added

    • :url [String] (required) the actual URL the content should link to

    • :openInNewWindow [Boolean] (false) Should the content open in a new window

  • args (Hash)

    a customizable set of options

Options Hash (**args):

  • :parentFolderId (String)

    ID of folder to place content in

Returns:


70
71
72
73
74
75
# File 'lib/seismic_api/teamsites.rb', line 70

def add_url(teamsiteId:, name:, url:, **args)
  request.post(
    "#{teamsites_url}/#{teamsiteId}/urls",
    body: { url: url, name: name, **args }
  )
end

#allSeismicAPI::Response

Return all teamsites


27
28
29
# File 'lib/seismic_api/teamsites.rb', line 27

def all
  request.get(teamsites_url)
end

#find(id:) ⇒ SeismicAPI::Response

Find a specific teamsite

Parameters:

  • id (String)

    id of teamsite

Returns:


37
38
39
# File 'lib/seismic_api/teamsites.rb', line 37

def find(id:)
  request.get("#{teamsites_url}/#{id}")
end

#items(teamsiteId:, **query) ⇒ SeismicAPI::Response

Query for items

Parameters:

  • teamsiteId (String)

    ID of teamsite

  • query (Hash)

    you must supply at least one option to query by

Options Hash (**query):

  • :externalId (String)

    query by externalId

  • :externalConnectionId (String)

    query by externalConnectionId

Returns:


120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/seismic_api/teamsites.rb', line 120

def items(teamsiteId:, **query)
  unless query[:externalId] || query[:externalConnectionId]
    raise ArgumentError,
      "Must suppy one of externalId or "\
      "externalConnectionId as a query option"
  end

  request.get(
    "#{teamsites_url}/#{teamsiteId}/items",
    params: query
  )
end

#publish(teamsiteId:, content:, **args) ⇒ SeismicAPI::Response

Publish given library content

Parameters:

  • teamsiteId (String)

    ID of teamsite

  • content (Array<{id=>String}>)

    ids for content to be published

Returns:


91
92
93
94
95
96
# File 'lib/seismic_api/teamsites.rb', line 91

def publish(teamsiteId:, content:, **args)
  request.post(
    "#{teamsites_url}/#{teamsiteId}/publish",
    body: { content: content, **args }
  )
end

#unpublish(teamsiteId:, libraryContentId:) ⇒ SeismicAPI::Response

Unpublish given library content

Parameters:

  • teamsiteId (String)

    ID of teamsite

  • libraryContentId (String)

    ID of content

Returns:


105
106
107
108
109
# File 'lib/seismic_api/teamsites.rb', line 105

def unpublish(teamsiteId:, libraryContentId:)
  request.put(
    "#{teamsites_url}/#{teamsiteId}/items/#{libraryContentId}/unpublish"
  )
end

#update_url(teamsiteId:, contentId:, **args) ⇒ Object


77
78
79
80
81
82
# File 'lib/seismic_api/teamsites.rb', line 77

def update_url(teamsiteId:, contentId:, **args)
  request.patch(
    "#{teamsites_url}/#{teamsiteId}/urls/#{contentId}",
    body: args
  )
end