gitlab_support_readiness 1.0.11 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/support_readiness/calendly/client.rb +64 -0
- data/lib/support_readiness/calendly/configuration.rb +45 -0
- data/lib/support_readiness/calendly/organization_memberships.rb +67 -0
- data/lib/support_readiness/calendly/organizations.rb +123 -0
- data/lib/support_readiness/calendly/users.rb +105 -0
- data/lib/support_readiness/calendly.rb +16 -0
- data/lib/support_readiness/client.rb +88 -1
- data/lib/support_readiness/dates.rb +90 -0
- data/lib/support_readiness/gitlab/configuration.rb +0 -1
- data/lib/support_readiness/gitlab/groups.rb +35 -0
- data/lib/support_readiness/gitlab/jobs.rb +189 -0
- data/lib/support_readiness/gitlab/markdown.rb +37 -0
- data/lib/support_readiness/gitlab/merge_requests.rb +127 -0
- data/lib/support_readiness/gitlab/namespaces.rb +22 -0
- data/lib/support_readiness/gitlab/pipelines.rb +191 -0
- data/lib/support_readiness/gitlab/projects.rb +85 -1
- data/lib/support_readiness/gitlab/repositories.rb +174 -0
- data/lib/support_readiness/gitlab/users.rb +24 -0
- data/lib/support_readiness/gitlab.rb +4 -0
- data/lib/support_readiness/google_calendar/client.rb +59 -0
- data/lib/support_readiness/google_calendar/configuration.rb +39 -0
- data/lib/support_readiness/google_calendar/events.rb +169 -0
- data/lib/support_readiness/google_calendar.rb +14 -0
- data/lib/support_readiness/mailgun/bounces.rb +103 -0
- data/lib/support_readiness/mailgun/client.rb +65 -0
- data/lib/support_readiness/mailgun/configuration.rb +46 -0
- data/lib/support_readiness/mailgun/emails.rb +95 -0
- data/lib/support_readiness/mailgun.rb +15 -0
- data/lib/support_readiness/pagerduty/escalation_policies.rb +1 -1
- data/lib/support_readiness/pagerduty/schedules.rb +27 -3
- data/lib/support_readiness/pagerduty/services.rb +1 -1
- data/lib/support_readiness/pagerduty/users.rb +197 -0
- data/lib/support_readiness/pagerduty.rb +1 -0
- data/lib/support_readiness/repos/articles.rb +335 -0
- data/lib/support_readiness/repos/automations.rb +247 -0
- data/lib/support_readiness/repos/groups.rb +188 -0
- data/lib/support_readiness/repos/macros.rb +224 -0
- data/lib/support_readiness/repos/organization_fields.rb +193 -0
- data/lib/support_readiness/repos/sla_policies.rb +192 -0
- data/lib/support_readiness/repos/ticket_fields.rb +200 -0
- data/lib/support_readiness/repos/ticket_forms.rb +200 -0
- data/lib/support_readiness/repos/triggers.rb +255 -0
- data/lib/support_readiness/repos/user_fields.rb +201 -0
- data/lib/support_readiness/repos/views.rb +362 -0
- data/lib/support_readiness/repos.rb +22 -0
- data/lib/support_readiness/salesforce/accounts.rb +109 -0
- data/lib/support_readiness/salesforce/cases.rb +109 -0
- data/lib/support_readiness/salesforce/client.rb +64 -0
- data/lib/support_readiness/salesforce/configuration.rb +49 -0
- data/lib/support_readiness/salesforce/queries.rb +62 -0
- data/lib/support_readiness/salesforce.rb +16 -0
- data/lib/support_readiness/slack/client.rb +63 -0
- data/lib/support_readiness/slack/configuration.rb +43 -0
- data/lib/support_readiness/slack/messages.rb +37 -0
- data/lib/support_readiness/slack.rb +14 -0
- data/lib/support_readiness/zendesk/app_job_statuses.rb +140 -0
- data/lib/support_readiness/zendesk/apps.rb +209 -0
- data/lib/support_readiness/zendesk/automations.rb +1 -2
- data/lib/support_readiness/zendesk/macros.rb +1 -3
- data/lib/support_readiness/zendesk/organization_fields.rb +1 -1
- data/lib/support_readiness/zendesk/theme_job_statuses.rb +136 -0
- data/lib/support_readiness/zendesk/themes.rb +303 -0
- data/lib/support_readiness/zendesk/ticket_field_options.rb +110 -0
- data/lib/support_readiness/zendesk/ticket_fields.rb +85 -16
- data/lib/support_readiness/zendesk/ticket_forms.rb +65 -2
- data/lib/support_readiness/zendesk/tickets.rb +77 -0
- data/lib/support_readiness/zendesk/triggers.rb +1 -2
- data/lib/support_readiness/zendesk/user_field_options.rb +110 -0
- data/lib/support_readiness/zendesk/user_fields.rb +257 -0
- data/lib/support_readiness/zendesk/views.rb +49 -2
- data/lib/support_readiness/zendesk.rb +7 -0
- data/lib/support_readiness.rb +16 -0
- metadata +122 -2
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
# Defines the module Salesforce
|
6
|
+
module Salesforce
|
7
|
+
##
|
8
|
+
# Defines the class Configuration within the module {Readiness::Salesforce}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.12
|
12
|
+
class Configuration
|
13
|
+
attr_accessor :api_version, :client_id, :client_secret, :host, :password, :security_token, :username
|
14
|
+
|
15
|
+
##
|
16
|
+
# Creates a new {Readiness::Salesforce::Configuration} instance
|
17
|
+
#
|
18
|
+
# @author Jason Colyer
|
19
|
+
# @since 1.0.12
|
20
|
+
# @example
|
21
|
+
# require 'support_readiness'
|
22
|
+
# config = Readiness::Salesforce::Configuration.new
|
23
|
+
# config.api_version = '58.0'
|
24
|
+
# config.client_id = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789'
|
25
|
+
# config.client_secret = 'XYZ789'
|
26
|
+
# config.password = 'p@ssw0rd!'
|
27
|
+
# config.security_token = 'ABC123'
|
28
|
+
# config.username = 'alice@example.com'
|
29
|
+
# pp config
|
30
|
+
# # => #<Readiness::Salesforce::Configuration:0x00007f352fdd1420
|
31
|
+
# @api_version="58.0",
|
32
|
+
# @client_id="ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789",
|
33
|
+
# @client_secret="XYZ789",
|
34
|
+
# @host="login.salesforce.com",
|
35
|
+
# @password="p@ssw0rd!",
|
36
|
+
# @security_token="ABC123",
|
37
|
+
# @username="alice@example.com">
|
38
|
+
def initialize
|
39
|
+
@api_version = ''
|
40
|
+
@client_id = ''
|
41
|
+
@client_secret = ''
|
42
|
+
@host = 'login.salesforce.com'
|
43
|
+
@password = ''
|
44
|
+
@security_token = ''
|
45
|
+
@username = ''
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
# Defines the module Salesforce
|
6
|
+
module Salesforce
|
7
|
+
##
|
8
|
+
# Defines the class Queries within the module {Readiness::Salesforce}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.12
|
12
|
+
class Queries < Readiness::Client
|
13
|
+
attr_accessor :syntax
|
14
|
+
|
15
|
+
##
|
16
|
+
# Creates a new {Readiness::Salesforce::Queries} instance
|
17
|
+
#
|
18
|
+
# @author Jason Colyer
|
19
|
+
# @since 1.0.12
|
20
|
+
# @param syntax [String] The query syntax to use
|
21
|
+
# @example
|
22
|
+
# require 'support_readiness'
|
23
|
+
# query = Readiness::Salesforce::Queries.new
|
24
|
+
# query.syntax = 'SELECT Name FROM Account LIMIT 5'
|
25
|
+
# pp query
|
26
|
+
# # => #<Readiness::Salesforce::Queries:0x00007f5383091ab8 @syntax="SELECT Name FROM Account LIMIT 5">
|
27
|
+
# @example
|
28
|
+
# require 'support_readiness'
|
29
|
+
# query = Readiness::Salesforce::Queries.new('SELECT Name FROM Account LIMIT 5')
|
30
|
+
# pp query
|
31
|
+
# # => #<Readiness::Salesforce::Queries:0x00007f5383091ab8 @syntax="SELECT Name FROM Account LIMIT 5">
|
32
|
+
def initialize(syntax = '')
|
33
|
+
@syntax = syntax
|
34
|
+
end
|
35
|
+
|
36
|
+
##
|
37
|
+
# Runs a SOQL query. This will exit on error
|
38
|
+
#
|
39
|
+
# @author Jason Colyer
|
40
|
+
# @since 1.0.12
|
41
|
+
# @param client [Object] An instance of {Readiness::Salesforce::Client}
|
42
|
+
# @param query [Object] A {Readiness::Salesforce::Queries} instance
|
43
|
+
# @return [Array]
|
44
|
+
# @example
|
45
|
+
# config = Readiness::Salesforce::Configuration.new
|
46
|
+
# config.api_version = '58.0'
|
47
|
+
# config.client_id = ENV.fetch('SFDC_CLIENTID')
|
48
|
+
# config.client_secret = ENV.fetch('SFDC_CLIENTSECRET')
|
49
|
+
# config.password = ENV.fetch('SFDC_PASSWORD')
|
50
|
+
# config.security_token = ENV.fetch('SFDC_SECURITYTOKEN')
|
51
|
+
# config.username = ENV.fetch('SFDC_USERNAME')
|
52
|
+
# client = Readiness::Salesforce::Client.new(config)
|
53
|
+
# query = Readiness::Salesforce::Queries.new('SELECT Name FROM Account LIMIT 5')
|
54
|
+
# results = Readiness::Salesforce::Queries.run!(client, query)
|
55
|
+
# pp results.map { |a| a.Name }
|
56
|
+
# # => ["Account 1", "Account 2", "Account 3", "Account 4", "Account 5"]
|
57
|
+
def self.run!(client, query)
|
58
|
+
client.connection.query(query.syntax)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
##
|
6
|
+
# Defines the module Salesforce
|
7
|
+
# @author Jason Colyer
|
8
|
+
# @since 1.0.12
|
9
|
+
module Salesforce
|
10
|
+
require "#{__dir__}/salesforce/accounts"
|
11
|
+
require "#{__dir__}/salesforce/cases"
|
12
|
+
require "#{__dir__}/salesforce/client"
|
13
|
+
require "#{__dir__}/salesforce/configuration"
|
14
|
+
require "#{__dir__}/salesforce/queries"
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
# Defines the module Slack
|
6
|
+
module Slack
|
7
|
+
##
|
8
|
+
# Defines the class Client within the module {Readiness::Slack}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.12
|
12
|
+
class Client
|
13
|
+
attr_reader :connection
|
14
|
+
|
15
|
+
##
|
16
|
+
# Creates a new {Readiness::Slack::Client} instance
|
17
|
+
#
|
18
|
+
# @author Jason Colyer
|
19
|
+
# @since 1.0.12
|
20
|
+
# @param config [Object] An instance of {Readiness::Slack::Configuration}
|
21
|
+
# @example
|
22
|
+
# require 'support_readiness'
|
23
|
+
# config = Readiness::Slack::Configuration.new
|
24
|
+
# config.url = 'https://hooks.slack.com/services/T12345678/A12BC3EFGHI/1aBCDefgHIJKlmnOPQRsT1u2'
|
25
|
+
# client = Readiness::Slack::Client.new(config)
|
26
|
+
def initialize(config = Readiness::Slack::Configuration.new)
|
27
|
+
@connection = generate_connection(config)
|
28
|
+
end
|
29
|
+
|
30
|
+
##
|
31
|
+
# Used to generate the retry options passed to Faraday via faraday-retry
|
32
|
+
#
|
33
|
+
# @author Jason Colyer
|
34
|
+
# @since 1.0.12
|
35
|
+
# @param config [Object] An instance of {Readiness::Slack::Configuration}
|
36
|
+
# @return [Hash]
|
37
|
+
def retry_options(config)
|
38
|
+
{
|
39
|
+
max: config.retry_max,
|
40
|
+
interval: config.retry_interval,
|
41
|
+
interval_randomness: config.retry_randomness,
|
42
|
+
backoff_factor: config.retry_backoff,
|
43
|
+
exceptions: config.retry_exceptions
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# Used to generate a Faraday connection
|
49
|
+
#
|
50
|
+
# @author Jason Colyer
|
51
|
+
# @since 1.0.0
|
52
|
+
# @param config [Object] An instance of {Readiness::Slack::Configuration}
|
53
|
+
# @return [Object]
|
54
|
+
def generate_connection(config)
|
55
|
+
Faraday.new(config.url) do |c|
|
56
|
+
c.request :retry, retry_options(config)
|
57
|
+
c.adapter Faraday.default_adapter
|
58
|
+
c.headers['Content-Type'] = 'application/json'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
# Defines the module Slack
|
6
|
+
module Slack
|
7
|
+
##
|
8
|
+
# Defines the class Configuration within the module {Readiness::Slack}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.12
|
12
|
+
class Configuration
|
13
|
+
attr_accessor :url, :retry_options, :retry_max, :retry_interval, :retry_randomness, :retry_backoff, :retry_exceptions
|
14
|
+
|
15
|
+
##
|
16
|
+
# Creates a new {Readiness::Slack::Configuration} instance
|
17
|
+
#
|
18
|
+
# @author Jason Colyer
|
19
|
+
# @since 1.0.12
|
20
|
+
# @example
|
21
|
+
# require 'support_readiness'
|
22
|
+
# config = Readiness::Slack::Configuration.new
|
23
|
+
# config.url = 'https://hooks.slack.com/services/T12345678/A12BC3EFGHI/1aBCDefgHIJKlmnOPQRsT1u2'
|
24
|
+
# pp config
|
25
|
+
# # => #<Readiness::Slack::Configuration:0x00007f352fdd1420
|
26
|
+
# @url="https://hooks.slack.com/services/T12345678/A12BC3EFGHI/1aBCDefgHIJKlmnOPQRsT1u2"
|
27
|
+
# @retry_backoff=2,
|
28
|
+
# @retry_exceptions=
|
29
|
+
# [Errno::ETIMEDOUT, "Timeout::Error", Faraday::TimeoutError, Faraday::RetriableResponse, Faraday::ConnectionFailed],
|
30
|
+
# @retry_interval=1,
|
31
|
+
# @retry_max=5,
|
32
|
+
# @retry_randomness=0.5>
|
33
|
+
def initialize
|
34
|
+
@url = ''
|
35
|
+
@retry_max = 5
|
36
|
+
@retry_interval = 1
|
37
|
+
@retry_randomness = 0.5
|
38
|
+
@retry_backoff = 2
|
39
|
+
@retry_exceptions = Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS + [Faraday::ConnectionFailed]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
# Defines the module Slack
|
6
|
+
module Slack
|
7
|
+
##
|
8
|
+
# Defines the class Emails within the module {Readiness::Slack}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.12
|
12
|
+
class Messages < Readiness::Client
|
13
|
+
##
|
14
|
+
# Posts a message via Slack
|
15
|
+
#
|
16
|
+
# @author Jason Colyer
|
17
|
+
# @since 1.0.12
|
18
|
+
# @param client [Object] An instance of {Readiness::Slack::Client}
|
19
|
+
# @param params This is pretty flexible, can be a simply String to a complex Hash
|
20
|
+
# @return [Boolean]
|
21
|
+
# @example
|
22
|
+
# require 'support_readiness'
|
23
|
+
# config = Readiness::Slack::Configuration.new
|
24
|
+
# config.url = 'https://hooks.slack.com/services/T12345678/A12BC3EFGHI/1aBCDefgHIJKlmnOPQRsT1u2'
|
25
|
+
# client = Readiness::Slack::Client.new(config)
|
26
|
+
# message = 'Jason Test'
|
27
|
+
# pp Readiness::Slack::Messages.create!(client, message)
|
28
|
+
# # => true
|
29
|
+
def self.create!(client, params)
|
30
|
+
response = client.connection.post '', { text: params }.to_json
|
31
|
+
handle_request_error(1, 'Slack', response.status, { action: 'Create a message', id: client.url }) unless response.status == 200
|
32
|
+
true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
##
|
6
|
+
# Defines the module Slack
|
7
|
+
# @author Jason Colyer
|
8
|
+
# @since 1.0.12
|
9
|
+
module Slack
|
10
|
+
require "#{__dir__}/slack/client"
|
11
|
+
require "#{__dir__}/slack/configuration"
|
12
|
+
require "#{__dir__}/slack/messages"
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
# Defines the module Zendesk
|
6
|
+
module Zendesk
|
7
|
+
##
|
8
|
+
# Defines the class AppJobStatuses within the module {Readiness::Zendesk}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.12
|
12
|
+
class AppJobStatuses < Readiness::Client
|
13
|
+
attr_accessor :app_id, :app_url, :id, :message, :progress, :retry_in, :status, :total
|
14
|
+
|
15
|
+
##
|
16
|
+
# Creates a new {Readiness::Zendesk::AppJobStatuses} instance
|
17
|
+
#
|
18
|
+
# @author Jason Colyer
|
19
|
+
# @since 1.0.12
|
20
|
+
# @param object [Object] An instance of {Readiness::Zendesk::AppJobStatuses}
|
21
|
+
# @example
|
22
|
+
# require 'support_readiness'
|
23
|
+
# Readiness::Zendesk::AppJobStatuses.new
|
24
|
+
def initialize(object = {})
|
25
|
+
@app_id = object['app_id']
|
26
|
+
@app_url = object['app_url']
|
27
|
+
@id = object['id']
|
28
|
+
@message = object['message']
|
29
|
+
@progress = object['progress']
|
30
|
+
@retry_in = object['retry_in']
|
31
|
+
@status = object['status']
|
32
|
+
@total = object['total']
|
33
|
+
end
|
34
|
+
|
35
|
+
##
|
36
|
+
# Locates an app job status within Zendesk. This will not exit on error (except Authentication errors)
|
37
|
+
#
|
38
|
+
# @author Jason Colyer
|
39
|
+
# @since 1.0.12
|
40
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
41
|
+
# @param jid [String] The job status ID to find
|
42
|
+
# @return [Hash]
|
43
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/apps/apps/#get-job-status Zendesk API > Apps > Get job status
|
44
|
+
# @example
|
45
|
+
# require 'support_readiness'
|
46
|
+
# config = Readiness::Zendesk::Configuration.new
|
47
|
+
# config.username = 'alice@example.com'
|
48
|
+
# config.token = 'test123abc'
|
49
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
50
|
+
# client = Readiness::Zendesk::Client.new(config)
|
51
|
+
# job = Readiness::Zendesk::AppJobStatuses.find(client, '8b726e606741012ffc2d782bcb7848fe')
|
52
|
+
# pp job.status
|
53
|
+
# # => "completed"
|
54
|
+
def self.find(client, jid)
|
55
|
+
response = client.connection.get("apps/job_statuses/#{jid}")
|
56
|
+
handle_request_error(0, 'Zendesk', response.status, { action: 'get', id: jid }) unless response.status == 200
|
57
|
+
return AppJobStatuses.new(Oj.load(response.body)) if response.status == 200
|
58
|
+
|
59
|
+
Oj.load(response.body)
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Locates an app job status within Zendesk. This will exit on error
|
64
|
+
#
|
65
|
+
# @author Jason Colyer
|
66
|
+
# @since 1.0.12
|
67
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
68
|
+
# @param jid [String] The job status ID to find
|
69
|
+
# @return [Object]
|
70
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/job_statuses/#show-job-status Zendesk API > Job Statuses > Show Job Status
|
71
|
+
# @example
|
72
|
+
# require 'support_readiness'
|
73
|
+
# config = Readiness::Zendesk::Configuration.new
|
74
|
+
# config.username = 'alice@example.com'
|
75
|
+
# config.token = 'test123abc'
|
76
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
77
|
+
# client = Readiness::Zendesk::Client.new(config)
|
78
|
+
# job = Readiness::Zendesk::AppJobStatuses.find!(client, '8b726e606741012ffc2d782bcb7848fe')
|
79
|
+
# pp job.status
|
80
|
+
# # => "completed"
|
81
|
+
def self.find!(client, jid)
|
82
|
+
response = client.connection.get("apps/job_statuses/#{jid}")
|
83
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Find app job status', id: jid }) unless response.status == 200
|
84
|
+
AppJobStatuses.new(Oj.load(response.body))
|
85
|
+
end
|
86
|
+
|
87
|
+
##
|
88
|
+
# Waits for a job to complete. Be mindful of API limits when setting the wait interval
|
89
|
+
#
|
90
|
+
# @author Jason Colyer
|
91
|
+
# @since 1.0.12
|
92
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
93
|
+
# @param job [Object] An instance of {Readiness::Zendesk::AppJobStatuses}
|
94
|
+
# @param interval [Integer] The time (in seconds) between checks
|
95
|
+
# @param verbose [Boolean] Whether or not to output messages
|
96
|
+
# @return [Object] An instance of {Readiness::Zendesk::AppJobStatuses}
|
97
|
+
# @example
|
98
|
+
# require 'support_readiness'
|
99
|
+
# config = Readiness::Zendesk::Configuration.new
|
100
|
+
# config.username = 'alice@example.com'
|
101
|
+
# config.token = 'test123abc'
|
102
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
103
|
+
# client = Readiness::Zendesk::Client.new(config)
|
104
|
+
# job = Readiness::Zendesk::AppJobStatuses.find!(client, '8b726e606741012ffc2d782bcb7848fe')
|
105
|
+
# completed_job = Readiness::Zendesk::AppJobStatuses.wait_for_completetion(client, job, 10, true)
|
106
|
+
# # => Waiting 10 seconds before checking 8b726e606741012ffc2d782bcb7848fe
|
107
|
+
# # => Rechecking status of 8b726e606741012ffc2d782bcb7848fe...status is queued
|
108
|
+
# # => Waiting 10 seconds before checking 8b726e606741012ffc2d782bcb7848fe
|
109
|
+
# # => Rechecking status of 8b726e606741012ffc2d782bcb7848fe...status is working
|
110
|
+
# # => Waiting 10 seconds before checking 8b726e606741012ffc2d782bcb7848fe
|
111
|
+
# # => Rechecking status of 8b726e606741012ffc2d782bcb7848fe...status is completed
|
112
|
+
# # => Job is finished with status of completed
|
113
|
+
# pp completed_job.status
|
114
|
+
# # => "completed"
|
115
|
+
# @example
|
116
|
+
# require 'support_readiness'
|
117
|
+
# config = Readiness::Zendesk::Configuration.new
|
118
|
+
# config.username = 'alice@example.com'
|
119
|
+
# config.token = 'test123abc'
|
120
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
121
|
+
# client = Readiness::Zendesk::Client.new(config)
|
122
|
+
# job = Readiness::Zendesk::AppJobStatuses.find!(client, '8b726e606741012ffc2d782bcb7848fe')
|
123
|
+
# completed_job = Readiness::Zendesk::AppJobStatuses.wait_for_completetion(client, job, 5, false)
|
124
|
+
# pp completed_job.status
|
125
|
+
# # => "completed"
|
126
|
+
def self.wait_for_completetion(client, job, interval = 5, verbose = true)
|
127
|
+
loop do
|
128
|
+
puts "Waiting #{interval} seconds before checking #{job.id}" if verbose
|
129
|
+
sleep interval
|
130
|
+
print "Rechecking status of #{job.id}..." if verbose
|
131
|
+
job = AppJobStatuses.find!(client, job.id)
|
132
|
+
puts "status is #{job.status}" if verbose
|
133
|
+
break if %w[failed completed].include? job.status
|
134
|
+
end
|
135
|
+
puts "Job is finished with status of #{job.status}" if verbose
|
136
|
+
job
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,209 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
# Defines the module Zendesk
|
6
|
+
module Zendesk
|
7
|
+
##
|
8
|
+
# Defines the class Apps within the module {Readiness::Zendesk}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.12
|
12
|
+
class Apps < Readiness::Client
|
13
|
+
attr_accessor :author_email, :author_name, :author_url, :categories, :closed_preview, :default_locale, :deprecated, :featrure_color, :featured, :framework_version, :google_analytics_code, :id, :installable, :installation_instructions, :large_icon, :long_description, :marketing_only, :name, :obsolete, :owner_id, :paid, :parameters, :products, :promoted, :raw_installation_instructions, :raw_long_description, :remote_installation_url, :screenshots, :short_description, :single_install, :small_icon, :state, :terms_conditions_url, :version, :visibility
|
14
|
+
|
15
|
+
##
|
16
|
+
# Creates a new {Readiness::Zendesk::Apps} instance
|
17
|
+
#
|
18
|
+
# @author Jason Colyer
|
19
|
+
# @since 1.0.12
|
20
|
+
# @param object [Object] An instance of {Readiness::Zendesk::Apps}
|
21
|
+
# @example
|
22
|
+
# require 'support_readiness'
|
23
|
+
# Readiness::Zendesk::Apps.new
|
24
|
+
def initialize(object = {})
|
25
|
+
@author_email = object['author_email']
|
26
|
+
@author_name = object['author_name']
|
27
|
+
@author_url = object['author_url']
|
28
|
+
@categories = object['categories']
|
29
|
+
@closed_preview = object['closed_preview']
|
30
|
+
@default_locale = object['default_locale']
|
31
|
+
@deprecated = object['deprecated']
|
32
|
+
@featrure_color = object['featrure_color']
|
33
|
+
@featured = object['featured']
|
34
|
+
@framework_version = object['framework_version']
|
35
|
+
@google_analytics_code = object['google_analytics_code']
|
36
|
+
@id = object['id']
|
37
|
+
@installable = object['installable']
|
38
|
+
@installation_instructions = object['installation_instructions']
|
39
|
+
@large_icon = object['large_icon']
|
40
|
+
@long_description = object['long_description']
|
41
|
+
@marketing_only = object['marketing_only']
|
42
|
+
@name = object['name']
|
43
|
+
@obsolete = object['obsolete']
|
44
|
+
@owner_id = object['owner_id']
|
45
|
+
@paid = object['paid']
|
46
|
+
@parameters = object['parameters']
|
47
|
+
@products = object['products']
|
48
|
+
@promoted = object['promoted']
|
49
|
+
@raw_installation_instructions = object['raw_installation_instructions']
|
50
|
+
@raw_long_description = object['raw_long_description']
|
51
|
+
@remote_installation_url = object['remote_installation_url']
|
52
|
+
@screenshots = object['screenshots']
|
53
|
+
@short_description = object['short_description']
|
54
|
+
@single_install = object['single_install']
|
55
|
+
@small_icon = object['small_icon']
|
56
|
+
@state = object['state']
|
57
|
+
@terms_conditions_url = object['terms_conditions_url']
|
58
|
+
@version = object['version']
|
59
|
+
@visibility = object['visibility']
|
60
|
+
end
|
61
|
+
|
62
|
+
##
|
63
|
+
# Lists owned apps within Zendesk
|
64
|
+
#
|
65
|
+
# @author Jason Colyer
|
66
|
+
# @since 1.0.12
|
67
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
68
|
+
# @return [Array]
|
69
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/apps/apps/#list-owned-apps Zendesk API > Apps > List Owned Apps
|
70
|
+
# @example
|
71
|
+
# require 'support_readiness'
|
72
|
+
# config = Readiness::Zendesk::Configuration.new
|
73
|
+
# config.username = 'alice@example.com'
|
74
|
+
# config.token = 'test123abc'
|
75
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
76
|
+
# client = Readiness::Zendesk::Client.new(config)
|
77
|
+
# apps = Readiness::Zendesk::Apps.list(client)
|
78
|
+
# pp apps.first.name
|
79
|
+
# # => "Bookmarks"
|
80
|
+
def self.list(client)
|
81
|
+
response = client.connection.get 'apps/owned'
|
82
|
+
handle_request_error(0, 'Zendesk', response.status) unless response.status == 200
|
83
|
+
Oj.load(response.body)['apps'].map { |a| Apps.new(a) }
|
84
|
+
end
|
85
|
+
|
86
|
+
##
|
87
|
+
# Locates an app within Zendesk. This will not exit on error (except Authentication errors)
|
88
|
+
#
|
89
|
+
# @author Jason Colyer
|
90
|
+
# @since 1.0.12
|
91
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
92
|
+
# @param aid [Integer] The app ID to locate
|
93
|
+
# @return [Object]
|
94
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/apps/apps/#get-information-about-app Zendesk API > Apps > Get Information About App
|
95
|
+
# @example
|
96
|
+
# require 'support_readiness'
|
97
|
+
# config = Readiness::Zendesk::Configuration.new
|
98
|
+
# config.username = 'alice@example.com'
|
99
|
+
# config.token = 'test123abc'
|
100
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
101
|
+
# client = Readiness::Zendesk::Client.new(config)
|
102
|
+
# app = Readiness::Zendesk::Apps.find(client, 12345)
|
103
|
+
# pp app.name
|
104
|
+
# # => "Bookmarks"
|
105
|
+
def self.find(client, aid)
|
106
|
+
response = client.connection.get "apps/#{aid}"
|
107
|
+
handle_request_error(0, 'Zendesk', response.status, { action: 'get', id: aid }) unless response.status == 200
|
108
|
+
return Apps.new(Oj.load(response.body)) if response.status == 200
|
109
|
+
|
110
|
+
Oj.load(response.body)
|
111
|
+
end
|
112
|
+
|
113
|
+
##
|
114
|
+
# Locates an app within Zendesk. This will exit on error
|
115
|
+
#
|
116
|
+
# @author Jason Colyer
|
117
|
+
# @since 1.0.12
|
118
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
119
|
+
# @param aid [Integer] The app ID to locate
|
120
|
+
# @return [Object]
|
121
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/apps/apps/#get-information-about-app Zendesk API > Apps > Get Information About App
|
122
|
+
# @example
|
123
|
+
# require 'support_readiness'
|
124
|
+
# config = Readiness::Zendesk::Configuration.new
|
125
|
+
# config.username = 'alice@example.com'
|
126
|
+
# config.token = 'test123abc'
|
127
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
128
|
+
# client = Readiness::Zendesk::Client.new(config)
|
129
|
+
# app = Readiness::Zendesk::Apps.find!(client, 12345)
|
130
|
+
# pp app.name
|
131
|
+
# # => "Bookmarks"
|
132
|
+
def self.find!(client, aid)
|
133
|
+
response = client.connection.get "apps/#{aid}"
|
134
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Find app', id: aid }) unless response.status == 200
|
135
|
+
Apps.new(Oj.load(response.body))
|
136
|
+
end
|
137
|
+
|
138
|
+
##
|
139
|
+
# Creates a zip file from the current working directory for a Zendesk app. This will exit on error
|
140
|
+
#
|
141
|
+
# @author Jason Colyer
|
142
|
+
# @since 1.0.12
|
143
|
+
# @param location [location] The relative path to the location of the theme files
|
144
|
+
# @return [String] The path to the zip file
|
145
|
+
# @example
|
146
|
+
# require 'support_readiness'
|
147
|
+
# file = Readiness::Zendesk::Apps.package!
|
148
|
+
# pp file
|
149
|
+
# # => "data/20241007151228578.zip"
|
150
|
+
def self.package!(location = './')
|
151
|
+
item_list = %w[ assets translations manifest.json ]
|
152
|
+
create_package!(item_list, location)
|
153
|
+
end
|
154
|
+
|
155
|
+
##
|
156
|
+
# Uploads a zip file from the current working directory for a Zendesk app. This will exit on erorr
|
157
|
+
#
|
158
|
+
# @author Jason Colyer
|
159
|
+
# @since 1.0.12
|
160
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
161
|
+
# @param file [String] The path to the zip file
|
162
|
+
# @return [Integer] The upload ID
|
163
|
+
# @example
|
164
|
+
# require 'support_readiness'
|
165
|
+
# config = Readiness::Zendesk::Configuration.new
|
166
|
+
# config.username = 'alice@example.com'
|
167
|
+
# config.token = 'test123abc'
|
168
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
169
|
+
# client = Readiness::Zendesk::Client.new(config)
|
170
|
+
# file = Readiness::Zendesk::Apps.package!
|
171
|
+
# job_id = Readiness::Zendesk::Apps.upload!(client, file)
|
172
|
+
# pp job_id
|
173
|
+
# # => 123
|
174
|
+
def self.upload!(client, file)
|
175
|
+
response = client.upload_connection.post 'apps/uploads', { uploaded_data: ::Faraday::UploadIO.new(file, 'application.zip') }
|
176
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Upload app', id: file }) unless response.status == 200
|
177
|
+
Oj.load(response.body)['id']
|
178
|
+
end
|
179
|
+
|
180
|
+
##
|
181
|
+
# Performs an app update job. This will exit on erorr
|
182
|
+
#
|
183
|
+
# @author Jason Colyer
|
184
|
+
# @since 1.0.12
|
185
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
186
|
+
# @param app [Object] An instance of {Readiness::Zendesk::Apps}
|
187
|
+
# @return [Object] An instance of {Readiness::Zendesk::AppJobStatuses}
|
188
|
+
# @example
|
189
|
+
# require 'support_readiness'
|
190
|
+
# config = Readiness::Zendesk::Configuration.new
|
191
|
+
# config.username = 'alice@example.com'
|
192
|
+
# config.token = 'test123abc'
|
193
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
194
|
+
# client = Readiness::Zendesk::Client.new(config)
|
195
|
+
# app = Readiness::Zendesk::Apps.find!(client, 123)
|
196
|
+
# job = Readiness::Zendesk::Apps.update!(client, app)
|
197
|
+
# completed_job = Readiness::Zendesk::AppJobStatuses.wait_for_completetion(client, job, 5, false)
|
198
|
+
# pp completed_job.status
|
199
|
+
# # => "completed"
|
200
|
+
def self.update!(client, app)
|
201
|
+
file = package!
|
202
|
+
upload_id = upload!(client, file)
|
203
|
+
response = client.connection.put "apps/#{app.id}", { upload_id: upload_id }.to_json
|
204
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Update app', id: app.id }) unless response.status == 200
|
205
|
+
AppJobStatuses.find!(client, Oj.load(response.body)['job_id'])
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|
209
|
+
end
|
@@ -10,7 +10,7 @@ module Readiness
|
|
10
10
|
# @author Jason Colyer
|
11
11
|
# @since 1.0.0
|
12
12
|
class Automations < Readiness::Client
|
13
|
-
attr_accessor :actions, :active, :conditions, :
|
13
|
+
attr_accessor :actions, :active, :conditions, :id, :position, :title
|
14
14
|
|
15
15
|
##
|
16
16
|
# Creates a new {Readiness::Zendesk::Automations} instance
|
@@ -25,7 +25,6 @@ module Readiness
|
|
25
25
|
@actions = object['actions']
|
26
26
|
@active = object['active']
|
27
27
|
@conditions = object['conditions']
|
28
|
-
@default = object['default']
|
29
28
|
@id = object['id']
|
30
29
|
@position = object['position']
|
31
30
|
@title = object['title']
|
@@ -10,7 +10,7 @@ module Readiness
|
|
10
10
|
# @author Jason Colyer
|
11
11
|
# @since 1.0.0
|
12
12
|
class Macros < Readiness::Client
|
13
|
-
attr_accessor :actions, :active, :
|
13
|
+
attr_accessor :actions, :active, :description, :id, :restriction, :title
|
14
14
|
|
15
15
|
##
|
16
16
|
# Creates a new {Readiness::Zendesk::Macros} instance
|
@@ -24,10 +24,8 @@ module Readiness
|
|
24
24
|
def initialize(object = {})
|
25
25
|
@actions = object['actions']
|
26
26
|
@active = object['active']
|
27
|
-
@default = object['default']
|
28
27
|
@description = object['description']
|
29
28
|
@id = object['id']
|
30
|
-
@position = object['position']
|
31
29
|
@restriction = object['restriction']
|
32
30
|
@title = object['title']
|
33
31
|
end
|