Class: KineticSdk::Discussions
- Inherits:
-
Object
- Object
- KineticSdk::Discussions
- Includes:
- Utils::KineticHttpUtils
- Defined in:
- lib/kinetic_sdk/discussions/discussions-sdk.rb,
lib/kinetic_sdk/discussions/lib/meta.rb,
lib/kinetic_sdk/discussions/lib/messages.rb,
lib/kinetic_sdk/discussions/lib/discussions.rb,
lib/kinetic_sdk/discussions/lib/invitations.rb,
lib/kinetic_sdk/discussions/lib/participants.rb,
lib/kinetic_sdk/discussions/lib/related_items.rb
Overview
Discussions is a Ruby class that acts as a wrapper for the Kinetic Discussions REST API without having to make explicit HTTP requests.
Instance Attribute Summary collapse
-
#api_url ⇒ Object
readonly
Returns the value of attribute api_url.
-
#jwt ⇒ Object
readonly
Returns the value of attribute jwt.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#space_slug ⇒ Object
readonly
Returns the value of attribute space_slug.
-
#topics_ws_server ⇒ Object
readonly
Returns the value of attribute topics_ws_server.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
-
#add_discussion(properties = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a Discussion.
-
#add_invitation_by_email(discussion_id, email, message = nil, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Invite an email that doesn't have a user account.
-
#add_invitation_by_username(discussion_id, username, message = nil, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Invite a user that already has an account.
-
#add_message(discussion_id, message, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a Message without attachments.
-
#add_message_with_attachments(discussion_id, properties = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a Message with attachments.
-
#add_participant(discussion_id, username, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Create a participant for an existing user.
-
#add_related_item(discussion_id, type, key, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a Related Item to a discussion.
-
#app_version(headers = header_accept_json) ⇒ KineticSdk::Utils::KineticHttpResponse
Retrieve Discussions application version.
-
#delete_discussion(discussion_id, headers = header_bearer_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Discussion.
-
#delete_invitation_by_email(discussion_id, email, headers = header_bearer_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete an email invitation.
-
#delete_invitation_by_username(discussion_id, username, headers = header_bearer_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a user invitation.
-
#delete_participant(discussion_id, username, headers = header_bearer_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a participant.
-
#delete_related_item(discussion_id, type, key, headers = header_bearer_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Related Item from a discussion.
-
#download_message_attachment(discussion_id, message_id, document_id, filename, params = {}, headers = header_bearer_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Download a message attachment.
-
#export_discussion_attachments(discussion_id, params = {}, headers = header_bearer_auth) ⇒ Object
Export all discussion attachments.
-
#export_message_attachment(discussion_id, message_id, document_id, filename, params = {}, headers = header_bearer_auth) ⇒ Object
Export a message attachment.
-
#find_discussion(discussion_id, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a Discussion.
-
#find_discussions(params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Discussions.
-
#find_invitation_by_email(discussion_id, email, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find an invitation in a discussion by email.
-
#find_invitation_by_username(discussion_id, username, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find an invitation in a discussion by username.
-
#find_invitations(discussion_id, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find invitations in a discussion.
-
#find_message(discussion_id, message_id, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a Message in a Discussion.
-
#find_messages(discussion_id, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Messages in a Discussion.
-
#find_participant(discussion_id, username, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a participant in a discussion.
-
#find_participants(discussion_id, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find participants in a discussion.
-
#find_related_item(discussion_id, type, key, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a Related Item in a Discussion.
-
#find_related_items(discussion_id, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Related Items in a Discussion.
-
#generate_jwt(options = {}) ⇒ Object
Generate a JWT for bearer authentication based on the user credentials, and oauth client configuration.
-
#initialize(opts) ⇒ Discussions
constructor
Initalize the Discussions SDK with the web server URL and configuration user credentials, along with any custom option values.
-
#kinetic_core_sdk(options) ⇒ Object
Creates a reference to the Kinetic Request CE SDK.
-
#resend_invitation_by_email(discussion_id, email, message, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Resend an email invitation.
-
#resend_invitation_by_username(discussion_id, username, message, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Resend a user invitation.
-
#update_discussion(discussion_id, properties = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a Discussion.
-
#update_message(discussion_id, message_id, message, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a Message without new attachments.
-
#update_message_with_attachments(discussion_id, message_id, message, attachments = [], headers = header_bearer_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a Message with new attachments.
-
#update_participant(discussion_id, username, properties = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a participant in a discussion.
Methods included from Utils::KineticHttpUtils
#default_headers, default_headers, #default_jwt_headers, default_jwt_headers, #delete, #encode, #gateway_retry_delay, #gateway_retry_limit, #get, #head, #header_accept_json, header_accept_json, #header_basic_auth, header_basic_auth, header_bearer_auth, #header_bearer_auth, #header_content_json, header_content_json, header_user_agent, #header_user_agent, #max_redirects, #mimetype, #patch, #post, #post_multipart, #put, #redirect_url, #stream_download_to_file
Constructor Details
#initialize(opts) ⇒ Discussions
Initalize the Discussions SDK with the web server URL and configuration user credentials, along with any custom option values.
Example: using a configuration file
KineticSdk::Discussions.new({
config_file: "/opt/config1.yaml"
})
Example: space user properties hash
KineticSdk::Discussions.new({
app_server_url: "http://localhost:8080",
space: "foo",
username: "admin",
password: "admin",
options: {
log_level: "debug",
export_directory: "/opt/exports/discussions",
oauth_client_id: "my-oauth-client-id",
oauth_client_secret: "secret",
ssl_verify_mode: "peer",
ssl_ca_file: "/usr/local/self_signing_ca.pem"
}
})
Example: system user properties hash
KineticSdk::Discussions.new({
app_server_url: "http://localhost:8080",
username: "admin",
password: "password",
options: {
log_level: "debug",
oauth_client_id: "my-oauth-client-id",
oauth_client_secret: "secret",
ssl_verify_mode: "peer",
ssl_ca_file: "/usr/local/self_signing_ca.pem"
}
})
If the +config_file+ option is present, it will be loaded first, and any additional options will overwrite any values in the config file
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/kinetic_sdk/discussions/discussions-sdk.rb', line 88 def initialize(opts) # initialize any variables = {} # process the configuration file if it was provided unless opts[:config_file].nil? .merge!(YAML::load_file opts[:config_file]) end # process the configuration hash if it was provided .merge!(opts) # allow either :app_server_url or :space_server_url, but not both if [:app_server_url] && [:space_server_url] raise StandardError.new "Expecting one of :app_server_url or :space_server_url, but not both." end if [:app_server_url].nil? && [:space_server_url].nil? raise StandardError.new "Expecting one of :app_server_url or :space_server_url." end # process any individual options @options = [:options] || {} # setup logging log_level = @options[:log_level] || @options["log_level"] log_output = @options[:log_output] || @options["log_output"] @logger = KineticSdk::Utils::KLogger.new(log_level, log_output) @username = [:username] @space_slug = [:space_slug] if [:topics_server_url] @topics_ws_server = "#{[:topics_server_url].gsub("http", "ws")}/#{@space_slug}/socket" end if [:discussions_server_url] @server = [:discussions_server_url].chomp("/") @api_url = "#{@server}/#{@space_slug}/app/api/v1" if @topics_ws_server.nil? @topics_ws_server = "#{@server.gsub("http", "ws")}/app/topics/socket" end elsif [:app_server_url] @server = [:app_server_url].chomp("/") @api_url = "#{@server}/#{@space_slug}/app/api/v1" if @topics_ws_server.nil? @topics_ws_server = "#{@server.gsub("http", "ws")}/#{@space_slug}/app/topics/socket" end else raise StandardError.new "The :space_slug option is required when using the :space_server_url option" if @space_slug.nil? @server = [:space_server_url].chomp("/") @api_url = "#{@server}/app/discussions/api/v1" if @topics_ws_server.nil? @topics_ws_server = "#{@server.gsub("http", "ws")}/app/topics/socket" end end @jwt = @space_slug.nil? ? nil : generate_jwt() @version = 1 end |
Instance Attribute Details
#api_url ⇒ Object (readonly)
Returns the value of attribute api_url.
13 14 15 |
# File 'lib/kinetic_sdk/discussions/discussions-sdk.rb', line 13 def api_url @api_url end |
#jwt ⇒ Object (readonly)
Returns the value of attribute jwt.
13 14 15 |
# File 'lib/kinetic_sdk/discussions/discussions-sdk.rb', line 13 def jwt @jwt end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
13 14 15 |
# File 'lib/kinetic_sdk/discussions/discussions-sdk.rb', line 13 def logger @logger end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
13 14 15 |
# File 'lib/kinetic_sdk/discussions/discussions-sdk.rb', line 13 def @options end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
13 14 15 |
# File 'lib/kinetic_sdk/discussions/discussions-sdk.rb', line 13 def server @server end |
#space_slug ⇒ Object (readonly)
Returns the value of attribute space_slug.
13 14 15 |
# File 'lib/kinetic_sdk/discussions/discussions-sdk.rb', line 13 def space_slug @space_slug end |
#topics_ws_server ⇒ Object (readonly)
Returns the value of attribute topics_ws_server.
13 14 15 |
# File 'lib/kinetic_sdk/discussions/discussions-sdk.rb', line 13 def topics_ws_server @topics_ws_server end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
13 14 15 |
# File 'lib/kinetic_sdk/discussions/discussions-sdk.rb', line 13 def username @username end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
13 14 15 |
# File 'lib/kinetic_sdk/discussions/discussions-sdk.rb', line 13 def version @version end |
Instance Method Details
#add_discussion(properties = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a Discussion
14 15 16 17 |
# File 'lib/kinetic_sdk/discussions/lib/discussions.rb', line 14 def add_discussion(properties={}, headers=default_jwt_headers) @logger.info("Adding the #{properties['title']} discussion") post("#{@api_url}/discussions", properties, headers) end |
#add_invitation_by_email(discussion_id, email, message = nil, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Invite an email that doesn't have a user account
11 12 13 14 15 16 |
# File 'lib/kinetic_sdk/discussions/lib/invitations.rb', line 11 def add_invitation_by_email(discussion_id, email, =nil, headers=default_jwt_headers) payload = { "email" => email } payload["message"] = unless .nil? @logger.info("Inviting #{email} to the #{discussion_id} Discussion") post("#{@api_url}/discussions/#{discussion_id}/invitations", payload, headers) end |
#add_invitation_by_username(discussion_id, username, message = nil, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Invite a user that already has an account
25 26 27 28 29 30 |
# File 'lib/kinetic_sdk/discussions/lib/invitations.rb', line 25 def add_invitation_by_username(discussion_id, username, =nil, headers=default_jwt_headers) payload = { "user" => { "username" => username } } payload["message"] = unless .nil? @logger.info("Inviting #{username} to the #{discussion_id} Discussion") post("#{@api_url}/discussions/#{discussion_id}/invitations", payload, headers) end |
#add_message(discussion_id, message, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a Message without attachments
If message parameter is a Hash, it assumes the message contains the
content
property set to an array of the expected tokens (type
and value
properties).
If message parameter is an Array, it assumes the message contains
the array of expected tokens (type
and value
properties).
If message parameter is a string, it builds up the message content
property as a single text
token with the value of the message
parameter.
21 22 23 24 25 |
# File 'lib/kinetic_sdk/discussions/lib/messages.rb', line 21 def (discussion_id, , headers=default_jwt_headers) payload = () @logger.info("Adding a message to the #{discussion_id} Discussion") post("#{@api_url}/discussions/#{discussion_id}/messages", payload, headers) end |
#add_message_with_attachments(discussion_id, properties = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a Message with attachments
If properties['message'] parameter is a Hash, it assumes the message
contains the content
property set to an array of the expected tokens
(type
and value
properties).
If properties['message'] parameter is an Array, it assumes the message
contains the array of expected tokens (type
and value
properties).
If properties['message'] parameter is a string, it builds up the message
content
property as a single text
token with the value of the
properties['message'] parameter.
46 47 48 49 50 51 |
# File 'lib/kinetic_sdk/discussions/lib/messages.rb', line 46 def (discussion_id, properties={}, headers=default_jwt_headers) payload = (properties['message']) payload["attachments"] = properties['attachments'] @logger.info("Adding a message to the #{discussion_id} Discussion") post_multipart("#{@api_url}/discussions/#{discussion_id}/messages", payload, headers) end |
#add_participant(discussion_id, username, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Create a participant for an existing user
10 11 12 13 14 |
# File 'lib/kinetic_sdk/discussions/lib/participants.rb', line 10 def add_participant(discussion_id, username, headers=default_jwt_headers) payload = { "username" => username } @logger.info("Participant #{username} joining the #{discussion_id} Discussion") post("#{@api_url}/discussions/#{discussion_id}/participants", payload, headers) end |
#add_related_item(discussion_id, type, key, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Add a Related Item to a discussion
11 12 13 14 15 |
# File 'lib/kinetic_sdk/discussions/lib/related_items.rb', line 11 def (discussion_id, type, key, headers=default_jwt_headers) payload = {"type": type, "key": key} @logger.info("Adding a related item of type #{type} and key #{key} to the #{discussion_id} Discussion") post("#{@api_url}/discussions/#{discussion_id}/relatedItems", payload, headers) end |
#app_version(headers = header_accept_json) ⇒ KineticSdk::Utils::KineticHttpResponse
Retrieve Discussions application version
8 9 10 11 |
# File 'lib/kinetic_sdk/discussions/lib/meta.rb', line 8 def app_version(headers=header_accept_json) @logger.info("Retrieving Discussions application version.") get("#{@api_url}/version", {}, headers) end |
#delete_discussion(discussion_id, headers = header_bearer_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Discussion
24 25 26 27 |
# File 'lib/kinetic_sdk/discussions/lib/discussions.rb', line 24 def delete_discussion(discussion_id, headers=header_bearer_auth) @logger.info("Deleting Discussion \"#{discussion_id}\"") delete("#{@api_url}/discussions/#{discussion_id}", headers) end |
#delete_invitation_by_email(discussion_id, email, headers = header_bearer_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete an email invitation
38 39 40 41 |
# File 'lib/kinetic_sdk/discussions/lib/invitations.rb', line 38 def delete_invitation_by_email(discussion_id, email, headers=header_bearer_auth) @logger.info("Deleting the email invitation to the #{discussion_id} Discussion for #{email}") delete("#{@api_url}/discussions/#{discussion_id}/invitations/#{encode(email)}?email=true", headers) end |
#delete_invitation_by_username(discussion_id, username, headers = header_bearer_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a user invitation
49 50 51 52 |
# File 'lib/kinetic_sdk/discussions/lib/invitations.rb', line 49 def delete_invitation_by_username(discussion_id, username, headers=header_bearer_auth) @logger.info("Deleting the user invitation to the #{discussion_id} Discussion for #{username}") delete("#{@api_url}/discussions/#{discussion_id}/invitations/#{encode(username)}", headers) end |
#delete_participant(discussion_id, username, headers = header_bearer_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a participant
22 23 24 25 |
# File 'lib/kinetic_sdk/discussions/lib/participants.rb', line 22 def delete_participant(discussion_id, username, headers=header_bearer_auth) @logger.info("Participant #{username} is leaving the #{discussion_id} Discussion") delete("#{@api_url}/discussions/#{discussion_id}/participants/#{encode(username)}", headers) end |
#delete_related_item(discussion_id, type, key, headers = header_bearer_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Delete a Related Item from a discussion
24 25 26 27 |
# File 'lib/kinetic_sdk/discussions/lib/related_items.rb', line 24 def (discussion_id, type, key, headers=header_bearer_auth) @logger.info("Deleting related item of type #{type} and key #{key} from the #{discussion_id} Discussion") delete("#{@api_url}/discussions/#{discussion_id}/relatedItems/#{encode(type)}/#{encode(key)}", payload, headers) end |
#download_message_attachment(discussion_id, message_id, document_id, filename, params = {}, headers = header_bearer_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Download a message attachment
WARNING This method downloads the entire attachment into memory. This may cause problems with large files. To stream the attachment in chunks to avoid consuming large amounts of memory, see the #export_message_attachment method.
139 140 141 142 |
# File 'lib/kinetic_sdk/discussions/lib/messages.rb', line 139 def (discussion_id, , document_id, filename, params={}, headers=header_bearer_auth) @logger.info("Downloading the #{filename} file attachment in the #{discussion_id} Discussion") get("#{@api_url}/discussions/#{discussion_id}/messages/#{}/files/#{document_id}/#{filename}", params, headers) end |
#export_discussion_attachments(discussion_id, params = {}, headers = header_bearer_auth) ⇒ Object
Export all discussion attachments
This method streams the attachments in chunks to avoid consuming large amounts of memory.
The message attachments will be saved to the
{export_directory}/{discussion_id}/files/{message_id}
directory, where:
- +export_directory+: the directory specified in the SDK configuration
- +discussion_id+: the id of the discussion
- +message_id+: the id of the message that contains the attachment
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/kinetic_sdk/discussions/lib/discussions.rb', line 82 def (discussion_id, params={}, headers=header_bearer_auth) raise StandardError.new "An export directory must be defined to export a file attachment." if @options[:export_directory].nil? @logger.info("Exporting all file attachments in the #{discussion_id} Discussion.") @logger.info("This may take a while.") # File Counter counter = 0 # write the files (discussion_id, params, headers).content['messages'].each do |m| = m['id'] updated_at = m['updatedAt'] m['content'].each do |item| if (item['type'] == "attachment") document_id = item['value']['documentId'] filename = item['value']['filename'] # count the files counter = counter + 1 # export the file attachments (discussion_id, , document_id, filename, params, headers) end end end @logger.info("Exported #{counter} file attachments for the #{discussion_id} Discussion") end |
#export_message_attachment(discussion_id, message_id, document_id, filename, params = {}, headers = header_bearer_auth) ⇒ Object
Export a message attachment
This method streams the attachment in chunks to avoid consuming large amounts of memory.
The message attachment will be saved to the
{export_directory}/{discussion_id}/files/{message_id}
directory, where:
- +export_directory+: the directory specified in the SDK configuration
- +discussion_id+: the id of the discussion
- +message_id+: the id of the message that contains the attachment
If you want to work with the attachment in code rather than automatically save it to a file, see the #download_message_attachment method.
165 166 167 168 169 170 171 172 173 |
# File 'lib/kinetic_sdk/discussions/lib/messages.rb', line 165 def (discussion_id, , document_id, filename, params={}, headers=header_bearer_auth) raise StandardError.new "An export directory must be defined to export a file attachment." if @options[:export_directory].nil? @logger.info("Exporting the #{filename} file attachment in the #{discussion_id} Discussion") # Create the export directory if it doesn't yet exist export_dir = FileUtils::mkdir_p(File.join(@options[:export_directory], discussion_id, "files", )) export_file = File.join(export_dir, filename) url = "#{@api_url}/discussions/#{discussion_id}/messages/#{}/files/#{document_id}/#{filename}" stream_download_to_file(export_file, url, params, headers) end |
#find_discussion(discussion_id, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a Discussion
45 46 47 48 |
# File 'lib/kinetic_sdk/discussions/lib/discussions.rb', line 45 def find_discussion(discussion_id, params={}, headers=default_jwt_headers) @logger.info("Finding the \"#{discussion_id}\" Discussion.") get("#{@api_url}/discussions/#{discussion_id}", params, headers) end |
#find_discussions(params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Discussions
34 35 36 37 |
# File 'lib/kinetic_sdk/discussions/lib/discussions.rb', line 34 def find_discussions(params={}, headers=default_jwt_headers) @logger.info("Finding Discussions.") get("#{@api_url}/discussions", params, headers) end |
#find_invitation_by_email(discussion_id, email, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find an invitation in a discussion by email
72 73 74 75 76 |
# File 'lib/kinetic_sdk/discussions/lib/invitations.rb', line 72 def find_invitation_by_email(discussion_id, email, params={}, headers=default_jwt_headers) params['email'] = 'true' if params['email'].nil? @logger.info("Finding the Invitation for email #{email} in the #{discussion_id} Discussion") get("#{@api_url}/discussions/#{discussion_id}/invitations/#{encode(email)}", params, headers) end |
#find_invitation_by_username(discussion_id, username, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find an invitation in a discussion by username
85 86 87 88 89 |
# File 'lib/kinetic_sdk/discussions/lib/invitations.rb', line 85 def find_invitation_by_username(discussion_id, username, params={}, headers=default_jwt_headers) params.delete('email') @logger.info("Finding the Invitation for user #{username} in the #{discussion_id} Discussion") get("#{@api_url}/discussions/#{discussion_id}/invitations/#{encode(username)}", params, headers) end |
#find_invitations(discussion_id, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find invitations in a discussion
60 61 62 63 |
# File 'lib/kinetic_sdk/discussions/lib/invitations.rb', line 60 def find_invitations(discussion_id, params={}, headers=default_jwt_headers) @logger.info("Finding Invitations in the #{discussion_id} Discussion") get("#{@api_url}/discussions/#{discussion_id}/invitations", params, headers) end |
#find_message(discussion_id, message_id, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a Message in a Discussion
71 72 73 74 |
# File 'lib/kinetic_sdk/discussions/lib/messages.rb', line 71 def (discussion_id, , params={}, headers=default_jwt_headers) @logger.info("Finding the #{} message in the #{discussion_id} Discussion") get("#{@api_url}/discussions/#{discussion_id}/messages/#{}", params, headers) end |
#find_messages(discussion_id, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Messages in a Discussion
59 60 61 62 |
# File 'lib/kinetic_sdk/discussions/lib/messages.rb', line 59 def (discussion_id, params={}, headers=default_jwt_headers) @logger.info("Finding messages in the #{discussion_id} Discussion") get("#{@api_url}/discussions/#{discussion_id}/messages", params, headers) end |
#find_participant(discussion_id, username, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a participant in a discussion
45 46 47 48 |
# File 'lib/kinetic_sdk/discussions/lib/participants.rb', line 45 def find_participant(discussion_id, username, params={}, headers=default_jwt_headers) @logger.info("Finding the #{username} Participant in the #{discussion_id} Discussion") get("#{@api_url}/discussions/#{discussion_id}/participants/#{encode(username)}", params, headers) end |
#find_participants(discussion_id, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find participants in a discussion
33 34 35 36 |
# File 'lib/kinetic_sdk/discussions/lib/participants.rb', line 33 def find_participants(discussion_id, params={}, headers=default_jwt_headers) @logger.info("Finding Participants in the #{discussion_id} Discussion") get("#{@api_url}/discussions/#{discussion_id}/participants", params, headers) end |
#find_related_item(discussion_id, type, key, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find a Related Item in a Discussion
48 49 50 51 |
# File 'lib/kinetic_sdk/discussions/lib/related_items.rb', line 48 def (discussion_id, type, key, params={}, headers=default_jwt_headers) @logger.info("Finding the related item of type #{type} and key #{key} in the #{discussion_id} Discussion") get("#{@api_url}/discussions/#{discussion_id}/relatedItems/#{encode(type)}/#{encode(key)}", params, headers) end |
#find_related_items(discussion_id, params = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Find Related Items in a Discussion
35 36 37 38 |
# File 'lib/kinetic_sdk/discussions/lib/related_items.rb', line 35 def (discussion_id, params={}, headers=default_jwt_headers) @logger.info("Finding related items in the #{discussion_id} Discussion") get("#{@api_url}/discussions/#{discussion_id}/relatedItems", params, headers) end |
#generate_jwt(options = {}) ⇒ Object
Generate a JWT for bearer authentication based on the user credentials, and oauth client configuration.
148 149 150 151 152 153 154 |
# File 'lib/kinetic_sdk/discussions/discussions-sdk.rb', line 148 def generate_jwt( = {}) oauth_client_id = [:options][:oauth_client_id] oauth_client_secret = [:options][:oauth_client_secret] jwt_response = kinetic_core_sdk().jwt_token(oauth_client_id, oauth_client_secret) jwt_response.content["access_token"] end |
#kinetic_core_sdk(options) ⇒ Object
Creates a reference to the Kinetic Request CE SDK
157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/kinetic_sdk/discussions/discussions-sdk.rb', line 157 def kinetic_core_sdk() = { space_slug: [:space_slug], username: [:username], password: [:password], options: [:options] || {}, } if [:app_server_url] [:app_server_url] = [:app_server_url] else [:space_server_url] = [:space_server_url] end KineticSdk::Core.new() end |
#resend_invitation_by_email(discussion_id, email, message, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Resend an email invitation
98 99 100 101 102 103 |
# File 'lib/kinetic_sdk/discussions/lib/invitations.rb', line 98 def resend_invitation_by_email(discussion_id, email, , headers=default_jwt_headers) payload = {} payload["message"] = unless .nil? @logger.info("Reinviting #{email} to the #{discussion_id} Discussion") put("#{@api_url}/discussions/#{discussion_id}/invitations/#{encode(email)}?email=true", payload, headers) end |
#resend_invitation_by_username(discussion_id, username, message, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Resend a user invitation
112 113 114 115 116 117 |
# File 'lib/kinetic_sdk/discussions/lib/invitations.rb', line 112 def resend_invitation_by_username(discussion_id, username, , headers=default_jwt_headers) payload = {} payload["message"] = unless .nil? @logger.info("Reinviting #{username} to the #{discussion_id} Discussion") put("#{@api_url}/discussions/#{discussion_id}/invitations/#{encode(username)}", payload, headers) end |
#update_discussion(discussion_id, properties = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a Discussion
62 63 64 65 |
# File 'lib/kinetic_sdk/discussions/lib/discussions.rb', line 62 def update_discussion(discussion_id, properties={}, headers=default_jwt_headers) @logger.info("Updating the \"#{discussion_id}\" Discussion.") put("#{@api_url}/discussions/#{discussion_id}", properties, headers) end |
#update_message(discussion_id, message_id, message, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a Message without new attachments
If message parameter is a Hash, it assumes the message contains the
content
property set to an array of the expected tokens (type
and value
properties).
If message parameter is an Array, it assumes the message contains
the array of expected tokens (type
and value
properties).
If message parameter is a string, it builds up the message content
property as a single text
token with the value of the message
parameter.
94 95 96 97 98 |
# File 'lib/kinetic_sdk/discussions/lib/messages.rb', line 94 def (discussion_id, , , headers=default_jwt_headers) payload = () @logger.info("Updating the #{} message in the #{discussion_id} Discussion") put("#{@api_url}/discussions/#{discussion_id}/messages/#{}", payload, headers) end |
#update_message_with_attachments(discussion_id, message_id, message, attachments = [], headers = header_bearer_auth) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a Message with new attachments
If message parameter is a Hash, it assumes the message contains the
content
property set to an array of the expected tokens (type
and value
properties).
If message parameter is an Array, it assumes the message contains
the array of expected tokens (type
and value
properties).
If message parameter is a string, it builds up the message content
property as a single text
token with the value of the message
parameter.
119 120 121 122 123 |
# File 'lib/kinetic_sdk/discussions/lib/messages.rb', line 119 def (discussion_id, , , =[], headers=header_bearer_auth) payload = { "message" => ().to_json, "attachments" => } @logger.info("Updating the #{} message in the #{discussion_id} Discussion") post_multipart("#{@api_url}/discussions/#{discussion_id}/messages/#{}", payload, headers) end |
#update_participant(discussion_id, username, properties = {}, headers = default_jwt_headers) ⇒ KineticSdk::Utils::KineticHttpResponse
Update a participant in a discussion
58 59 60 61 |
# File 'lib/kinetic_sdk/discussions/lib/participants.rb', line 58 def update_participant(discussion_id, username, properties={}, headers=default_jwt_headers) @logger.info("Updating the #{username} Participant in the #{discussion_id} Discussion") put("#{@api_url}/discussions/#{discussion_id}/participants/#{encode(username)}", properties, headers) end |