gitlab_support_readiness 1.0.11 → 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/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/projects.rb +36 -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 +2 -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 +120 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af0b51a6c4756ec281e1a95b11b4285679732fd2fef0477763ba91f311101ecf
|
4
|
+
data.tar.gz: b628588ccfa499ac5487b1e2e4162bb0a10645b3e0a93770e17b9cae3d7c2dfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 570055d78f7d5cedd8af65d927f771f6ff77a276a8a2cddc3ebab9d9ce6c0e04f11ae66241bfad730fc5a6cc9882348d1237e366bd412feb9cc544ef0b05081c
|
7
|
+
data.tar.gz: f77ba9593526b3375b39ea142e27775021ad7845debf03ba69ae26e642ce8b358516293a343743036ae38d13b956bc0d820134230cd20feeab3da14f3542a3af
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
# Defines the module Calendly
|
6
|
+
module Calendly
|
7
|
+
##
|
8
|
+
# Defines the class Client within the module {Readiness::Calendly}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.12
|
12
|
+
class Client
|
13
|
+
attr_reader :connection
|
14
|
+
|
15
|
+
##
|
16
|
+
# Creates a new {Readiness::Calendly::Client} instance
|
17
|
+
#
|
18
|
+
# @author Jason Colyer
|
19
|
+
# @since 1.0.12
|
20
|
+
# @param config [Object] An instance of {Readiness::Calendly::Configuration}
|
21
|
+
# @example
|
22
|
+
# require 'support_readiness'
|
23
|
+
# config = Readiness::GitLab::Configuration.new
|
24
|
+
# config.token = 'test123abc'
|
25
|
+
# client = Readiness::GitLab::Client.new(config)
|
26
|
+
def initialize(config = Readiness::Calendly::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::Calendly::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::Calendly::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
|
+
c.headers['Authorization'] = "Bearer #{config.token}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
# Defines the module Calendly
|
6
|
+
module Calendly
|
7
|
+
##
|
8
|
+
# Defines the class Configuration within the module {Readiness::Calendly}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.12
|
12
|
+
class Configuration
|
13
|
+
attr_accessor :url, :token, :retry_options, :retry_max, :retry_interval, :retry_randomness, :retry_backoff, :retry_exceptions
|
14
|
+
|
15
|
+
##
|
16
|
+
# Creates a new {Readiness::Calendly::Configuration} instance
|
17
|
+
#
|
18
|
+
# @author Jason Colyer
|
19
|
+
# @since 1.0.12
|
20
|
+
# @example
|
21
|
+
# require 'support_readiness'
|
22
|
+
# config = Readiness::Calendly::Configuration.new
|
23
|
+
# config.token = 'test123abc'
|
24
|
+
# pp config
|
25
|
+
# # => #<Readiness::Calendly::Configuration:0x00007f352fdd1420
|
26
|
+
# @retry_backoff=2,
|
27
|
+
# @retry_exceptions=
|
28
|
+
# [Errno::ETIMEDOUT, "Timeout::Error", Faraday::TimeoutError, Faraday::RetriableResponse, Faraday::ConnectionFailed],
|
29
|
+
# @retry_interval=1,
|
30
|
+
# @retry_max=5,
|
31
|
+
# @retry_randomness=0.5,
|
32
|
+
# @token="test123abc",
|
33
|
+
# @url="https://api.calendly.com">
|
34
|
+
def initialize
|
35
|
+
@url = 'https://api.calendly.com'
|
36
|
+
@token = ''
|
37
|
+
@retry_max = 5
|
38
|
+
@retry_interval = 1
|
39
|
+
@retry_randomness = 0.5
|
40
|
+
@retry_backoff = 2
|
41
|
+
@retry_exceptions = Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS + [Faraday::ConnectionFailed]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
# Defines the module Calendly
|
6
|
+
module Calendly
|
7
|
+
##
|
8
|
+
# Defines the class OrganizationMemberships within the module {Readiness::Calendly}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.12
|
12
|
+
class OrganizationMemberships < Readiness::Client
|
13
|
+
attr_accessor :created_at, :organization, :role, :updated_at, :uri, :user
|
14
|
+
|
15
|
+
##
|
16
|
+
# Creates a new {Readiness::Calendly::OrganizationMemberships} instance
|
17
|
+
#
|
18
|
+
# @author Jason Colyer
|
19
|
+
# @since 1.0.12
|
20
|
+
# @param object [Object] An instance of {Readiness::Calendly::OrganizationMemberships}
|
21
|
+
# @example
|
22
|
+
# require 'support_readiness'
|
23
|
+
# Readiness::Calendly::OrganizationMemberships.new
|
24
|
+
def initialize(object = {})
|
25
|
+
@created_at = object['created_at']
|
26
|
+
@organization = object['organization']
|
27
|
+
@role = object['role']
|
28
|
+
@updated_at = object['updated_at']
|
29
|
+
@uri = object['uri']
|
30
|
+
@user = (object['user'].nil? ? Users.new : Users.new(object['user']))
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Provides a list of organization memberships.
|
35
|
+
#
|
36
|
+
# @author Jason Colyer
|
37
|
+
# @since 1.0.12
|
38
|
+
# @param client [Object] An instance of {Readiness::Calendly::Client}
|
39
|
+
# @param organization [String] An instance of {Readiness::Calendly::Organizations}
|
40
|
+
# @return [Array]
|
41
|
+
# @see https://developer.calendly.com/api-docs/eaed2e61a6bc3-list-organization-memberships Calendly API > Organizations > List Organization Memberships
|
42
|
+
# @example
|
43
|
+
# require 'support_readiness'
|
44
|
+
# config = Readiness::Calendly::Configuration.new
|
45
|
+
# config.token = 'test123abc'
|
46
|
+
# client = Readiness::Calendly::Client.new(config)
|
47
|
+
# org = Readiness::Calendly::Organizations.find!(client, 'abc123')
|
48
|
+
# members = Readiness::Calendly::Organizations.members(client, org)
|
49
|
+
# pp members.first.name
|
50
|
+
# # => "Jason Colyer"
|
51
|
+
def self.list(client, organization)
|
52
|
+
members = []
|
53
|
+
opts = { organization: organization.uri, count: 100 }
|
54
|
+
loop do
|
55
|
+
response = client.connection.get "organization_memberships", opts
|
56
|
+
handle_request_error(0, 'Calendly', response.status, { action: 'get', id: organization.uri.split('/').last }) unless response.status == 200
|
57
|
+
body = Oj.load(response.body)
|
58
|
+
members += body['collection'].map { |c| OrganizationMemberships.new(c) }
|
59
|
+
break if body['pagination']['next_page_token'].nil?
|
60
|
+
|
61
|
+
opts = { organization: organization.uri, count: 100, page_token: body['pagination']['next_page_token'] }
|
62
|
+
end
|
63
|
+
members
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
# Defines the module Calendly
|
6
|
+
module Calendly
|
7
|
+
##
|
8
|
+
# Defines the class Organizations within the module {Readiness::Calendly}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.12
|
12
|
+
class Organizations < Readiness::Client
|
13
|
+
attr_accessor :created_at, :name, :plan, :stage, :updated_at, :uri
|
14
|
+
|
15
|
+
##
|
16
|
+
# Creates a new {Readiness::Calendly::Organizations} instance
|
17
|
+
#
|
18
|
+
# @author Jason Colyer
|
19
|
+
# @since 1.0.12
|
20
|
+
# @param object [Object] An instance of {Readiness::Calendly::Organizations}
|
21
|
+
# @example
|
22
|
+
# require 'support_readiness'
|
23
|
+
# Readiness::Calendly::Organizations.new
|
24
|
+
def initialize(object = {})
|
25
|
+
@created_at = object['created_at']
|
26
|
+
@name = object['name']
|
27
|
+
@plan = object['plan']
|
28
|
+
@stage = object['stage']
|
29
|
+
@updated_at = object['updated_at']
|
30
|
+
@uri = object['uri']
|
31
|
+
end
|
32
|
+
|
33
|
+
##
|
34
|
+
# Returns the current user's organization within Calendly.
|
35
|
+
#
|
36
|
+
# @author Jason Colyer
|
37
|
+
# @since 1.0.12
|
38
|
+
# @param client [Object] An instance of {Readiness::Calendly::Client}
|
39
|
+
# @return [Object] An instance of {Readiness::Calendly::Organizations}
|
40
|
+
# @see https://developer.calendly.com/api-docs/848e5e20591ee-organization Calendly API > Organizations > Organization
|
41
|
+
# @example
|
42
|
+
# require 'support_readiness'
|
43
|
+
# config = Readiness::Calendly::Configuration.new
|
44
|
+
# config.token = 'test123abc'
|
45
|
+
# client = Readiness::Calendly::Client.new(config)
|
46
|
+
# org = Readiness::Calendly::Organizations.current(client)
|
47
|
+
# pp org.name
|
48
|
+
# # => "GitLab Support"
|
49
|
+
def self.current(client)
|
50
|
+
user = Users.current(client)
|
51
|
+
Organizations.find(client, user.current_organization.split('/').last)
|
52
|
+
end
|
53
|
+
|
54
|
+
##
|
55
|
+
# Locates an organization within Calendly. This will not exit on error (except Authentication errors)
|
56
|
+
#
|
57
|
+
# @author Jason Colyer
|
58
|
+
# @since 1.0.12
|
59
|
+
# @param client [Object] An instance of {Readiness::Calendly::Client}
|
60
|
+
# @param oid [String] The organization ID to find
|
61
|
+
# @return [Object] An instance of {Readiness::Calendly::Organizations}
|
62
|
+
# @see https://developer.calendly.com/api-docs/848e5e20591ee-organization Calendly API > Organizations > Organization
|
63
|
+
# @example
|
64
|
+
# require 'support_readiness'
|
65
|
+
# config = Readiness::Calendly::Configuration.new
|
66
|
+
# config.token = 'test123abc'
|
67
|
+
# client = Readiness::Calendly::Client.new(config)
|
68
|
+
# org = Readiness::Calendly::Organizations.find(client, 'abc123')
|
69
|
+
# pp org.name
|
70
|
+
# # => "GitLab Support"
|
71
|
+
def self.find(client, oid)
|
72
|
+
response = client.connection.get "organizations/#{oid}"
|
73
|
+
handle_request_error(0, 'Calendly', response.status, { action: 'get', id: oid }) unless response.status == 200
|
74
|
+
Organizations.new(Oj.load(response.body)['resource'])
|
75
|
+
end
|
76
|
+
|
77
|
+
##
|
78
|
+
# Locates an organization within Calendly. This will exit on error
|
79
|
+
#
|
80
|
+
# @author Jason Colyer
|
81
|
+
# @since 1.0.12
|
82
|
+
# @param client [Object] An instance of {Readiness::Calendly::Client}
|
83
|
+
# @param oid [String] The organization ID to find
|
84
|
+
# @return [Object] An instance of {Readiness::Calendly::Organizations}
|
85
|
+
# @see https://developer.calendly.com/api-docs/848e5e20591ee-organization Calendly API > Organizations > Organization
|
86
|
+
# @example
|
87
|
+
# require 'support_readiness'
|
88
|
+
# config = Readiness::Calendly::Configuration.new
|
89
|
+
# config.token = 'test123abc'
|
90
|
+
# client = Readiness::Calendly::Client.new(config)
|
91
|
+
# org = Readiness::Calendly::Organizations.find!(client, 'abc123')
|
92
|
+
# pp org.name
|
93
|
+
# # => "GitLab Support"
|
94
|
+
def self.find!(client, oid)
|
95
|
+
response = client.connection.get "organizations/#{oid}"
|
96
|
+
handle_request_error(1, 'Calendly', response.status, { action: 'Find organization', id: oid }) unless response.status == 200
|
97
|
+
Organizations.new(Oj.load(response.body)['resource'])
|
98
|
+
end
|
99
|
+
|
100
|
+
##
|
101
|
+
# Provides a list of organization memberships. A wrapper for {OrganizationMemberships#list}
|
102
|
+
#
|
103
|
+
# @author Jason Colyer
|
104
|
+
# @since 1.0.12
|
105
|
+
# @param client [Object] An instance of {Readiness::Calendly::Client}
|
106
|
+
# @param organization [String] An instance of {Readiness::Calendly::Organizations}
|
107
|
+
# @return [Array]
|
108
|
+
# @see https://developer.calendly.com/api-docs/eaed2e61a6bc3-list-organization-memberships Calendly API > Organizations > List Organization Memberships
|
109
|
+
# @example
|
110
|
+
# require 'support_readiness'
|
111
|
+
# config = Readiness::Calendly::Configuration.new
|
112
|
+
# config.token = 'test123abc'
|
113
|
+
# client = Readiness::Calendly::Client.new(config)
|
114
|
+
# org = Readiness::Calendly::Organizations.find!(client, 'abc123')
|
115
|
+
# members = Readiness::Calendly::Organizations.members(client, org)
|
116
|
+
# pp members.first.name
|
117
|
+
# # => "Jason Colyer"
|
118
|
+
def self.members(client, organization)
|
119
|
+
Readiness::Calendly::OrganizationMemberships.list(client, organization)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
# Defines the module Calendly
|
6
|
+
module Calendly
|
7
|
+
##
|
8
|
+
# Defines the class Users within the module {Readiness::Calendly}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.12
|
12
|
+
class Users < Readiness::Client
|
13
|
+
attr_accessor :avatar_url, :created_at, :current_organization, :email, :name, :resource_type, :scheduling_url, :slug, :timezone, :updated_at, :uri
|
14
|
+
|
15
|
+
##
|
16
|
+
# Creates a new {Readiness::Calendly::Users} instance
|
17
|
+
#
|
18
|
+
# @author Jason Colyer
|
19
|
+
# @since 1.0.12
|
20
|
+
# @param object [Object] An instance of {Readiness::Calendly::Users}
|
21
|
+
# @example
|
22
|
+
# require 'support_readiness'
|
23
|
+
# Readiness::Calendly::Users.new
|
24
|
+
def initialize(object = {})
|
25
|
+
@avatar_url = object['avatar_url']
|
26
|
+
@created_at = object['created_at']
|
27
|
+
@current_organization = object['current_organization']
|
28
|
+
@email = object['email']
|
29
|
+
@name = object['name']
|
30
|
+
@resource_type = object['resource_type']
|
31
|
+
@scheduling_url = object['scheduling_url']
|
32
|
+
@slug = object['slug']
|
33
|
+
@timezone = object['timezone']
|
34
|
+
@updated_at = object['updated_at']
|
35
|
+
@uri = object['uri']
|
36
|
+
end
|
37
|
+
|
38
|
+
##
|
39
|
+
# Gets information on the current user
|
40
|
+
#
|
41
|
+
# @author Jason Colyer
|
42
|
+
# @since 1.0.12
|
43
|
+
# @param client [Object] An instance of {Readiness::Calendly::Client}
|
44
|
+
# @example
|
45
|
+
# require 'support_readiness'
|
46
|
+
# config = Readiness::Calendly::Configuration.new
|
47
|
+
# config.token = 'abc123'
|
48
|
+
# client = Readiness::Calendly::Client.new(config)
|
49
|
+
# user = Readiness::Calendly::Users.current(client)
|
50
|
+
# pp user.name
|
51
|
+
# # => "John Doe"
|
52
|
+
def self.current(client)
|
53
|
+
response = client.connection.get 'users/me'
|
54
|
+
handle_request_error(0, 'Calendly', response.status) unless response.status == 200
|
55
|
+
Users.new(Oj.load(response.body)['resource'])
|
56
|
+
end
|
57
|
+
|
58
|
+
##
|
59
|
+
# Locates an user within Calendly. This will not exit on error (except Authentication errors)
|
60
|
+
#
|
61
|
+
# @author Jason Colyer
|
62
|
+
# @since 1.0.12
|
63
|
+
# @param client [Object] An instance of {Readiness::Calendly::Client}
|
64
|
+
# @param uid [String] The user ID to find
|
65
|
+
# @return [Object] An instance of {Readiness::Calendly::Users}
|
66
|
+
# @see https://developer.calendly.com/api-docs/ff9832c5a6640-get-user Calendly API > Users > Get user
|
67
|
+
# @example
|
68
|
+
# require 'support_readiness'
|
69
|
+
# config = Readiness::Calendly::Configuration.new
|
70
|
+
# config.token = 'test123abc'
|
71
|
+
# client = Readiness::Calendly::Client.new(config)
|
72
|
+
# user = Readiness::Calendly::Users.find(client, 'abc123')
|
73
|
+
# pp user.name
|
74
|
+
# # => "Jason Colyer"
|
75
|
+
def self.find(client, uid)
|
76
|
+
response = client.connection.get "users/#{uid}"
|
77
|
+
handle_request_error(0, 'Calendly', response.status, { action: 'get', id: uid }) unless response.status == 200
|
78
|
+
Users.new(Oj.load(response.body)['resource'])
|
79
|
+
end
|
80
|
+
|
81
|
+
##
|
82
|
+
# Locates an user within Calendly. This will exit on error
|
83
|
+
#
|
84
|
+
# @author Jason Colyer
|
85
|
+
# @since 1.0.12
|
86
|
+
# @param client [Object] An instance of {Readiness::Calendly::Client}
|
87
|
+
# @param uid [String] The user ID to find
|
88
|
+
# @return [Object] An instance of {Readiness::Calendly::Users}
|
89
|
+
# @see https://developer.calendly.com/api-docs/ff9832c5a6640-get-user Calendly API > Users > Get user
|
90
|
+
# @example
|
91
|
+
# require 'support_readiness'
|
92
|
+
# config = Readiness::Calendly::Configuration.new
|
93
|
+
# config.token = 'test123abc'
|
94
|
+
# client = Readiness::Calendly::Client.new(config)
|
95
|
+
# user = Readiness::Calendly::Users.find!(client, 'abc123')
|
96
|
+
# pp user.name
|
97
|
+
# # => "Jason Colyer"
|
98
|
+
def self.find!(client, uid)
|
99
|
+
response = client.connection.get "users/#{uid}"
|
100
|
+
handle_request_error(1, 'Calendly', response.status, { action: 'Find user', id: uid }) unless response.status == 200
|
101
|
+
Users.new(Oj.load(response.body)['resource'])
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
##
|
6
|
+
# Defines the module Calendly
|
7
|
+
# @author Jason Colyer
|
8
|
+
# @since 1.0.12
|
9
|
+
module Calendly
|
10
|
+
require "#{__dir__}/calendly/client"
|
11
|
+
require "#{__dir__}/calendly/configuration"
|
12
|
+
require "#{__dir__}/calendly/users"
|
13
|
+
require "#{__dir__}/calendly/organization_memberships"
|
14
|
+
require "#{__dir__}/calendly/organizations"
|
15
|
+
end
|
16
|
+
end
|
@@ -127,7 +127,7 @@ module Readiness
|
|
127
127
|
# @param system [String] The system the error occurred on
|
128
128
|
# @param params [Hash] A Hash of information about the request
|
129
129
|
def self.bad_request_error(system, params)
|
130
|
-
puts "Action '#{params[:action]}' to ID #{params[:id]} on #{system} returned a
|
130
|
+
puts "Action '#{params[:action]}' to ID #{params[:id]} on #{system} returned a 400 error"
|
131
131
|
exit 1
|
132
132
|
end
|
133
133
|
|
@@ -143,5 +143,92 @@ module Readiness
|
|
143
143
|
pp params[:message]
|
144
144
|
exit 1
|
145
145
|
end
|
146
|
+
|
147
|
+
##
|
148
|
+
# Generates a Time String to be used in zip file generation
|
149
|
+
#
|
150
|
+
# @author Jason Colyer
|
151
|
+
# @since 1.0.12
|
152
|
+
def self.timestamp_filename
|
153
|
+
@name ||= Time.now.strftime('%Y%m%d%H%M%S%L')
|
154
|
+
end
|
155
|
+
|
156
|
+
##
|
157
|
+
# Generates a Time String to be used in zip file generation
|
158
|
+
#
|
159
|
+
# @author Jason Colyer
|
160
|
+
# @since 1.0.12
|
161
|
+
# @param item_list [Array] An Array of items to zip
|
162
|
+
# @return [String] The path to the zip file
|
163
|
+
def self.create_package!(item_list, input_dir = './')
|
164
|
+
@output_file = "data/#{timestamp_filename}.zip"
|
165
|
+
@input_dir = input_dir
|
166
|
+
Zip::File.open(@output_file, create: true) do |zipfile|
|
167
|
+
write_entries item_list, '', zipfile
|
168
|
+
end
|
169
|
+
@output_file
|
170
|
+
end
|
171
|
+
|
172
|
+
##
|
173
|
+
# Writes entries to a zip file
|
174
|
+
#
|
175
|
+
# @author Jason Colyer
|
176
|
+
# @since 1.0.12
|
177
|
+
# @param items [Array] An Array of items to zip
|
178
|
+
# @param path [String] The path to the items
|
179
|
+
# @param zipfile [Object] The Zip object
|
180
|
+
def self.write_entries(items, path, zipfile)
|
181
|
+
items.each do |i|
|
182
|
+
zipfile_path = path == '' ? i : File.join(path, i)
|
183
|
+
disk_file_path = File.join(@input_dir, zipfile_path)
|
184
|
+
if File.directory? disk_file_path
|
185
|
+
recursively_deflate_directory(disk_file_path, zipfile, zipfile_path)
|
186
|
+
else
|
187
|
+
put_into_archive(disk_file_path, zipfile, zipfile_path)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
##
|
193
|
+
# Recusrively zips a folder
|
194
|
+
#
|
195
|
+
# @author Jason Colyer
|
196
|
+
# @since 1.0.12
|
197
|
+
# @param disk_file_path [String] The path to the folder
|
198
|
+
# @param zipfile [Object] The Zip object
|
199
|
+
# @param zipfile_path [String] The path to the folder within the zip file
|
200
|
+
def self.recursively_deflate_directory(disk_file_path, zipfile, zipfile_path)
|
201
|
+
zipfile.mkdir zipfile_path
|
202
|
+
subdir = Dir.entries(disk_file_path) - %w[. ..]
|
203
|
+
write_entries subdir, zipfile_path, zipfile
|
204
|
+
end
|
205
|
+
|
206
|
+
##
|
207
|
+
# Adds an item to the zip file
|
208
|
+
#
|
209
|
+
# @author Jason Colyer
|
210
|
+
# @since 1.0.12
|
211
|
+
# @param disk_file_path [String] The path to the folder
|
212
|
+
# @param zipfile [Object] The Zip object
|
213
|
+
# @param zipfile_path [String] The path to the folder within the zip file
|
214
|
+
def self.put_into_archive(disk_file_path, zipfile, zipfile_path)
|
215
|
+
zipfile.add(zipfile_path, disk_file_path)
|
216
|
+
end
|
217
|
+
|
218
|
+
##
|
219
|
+
# Generate an ERB renderer for a specific file
|
220
|
+
#
|
221
|
+
# @author Jason Colyer
|
222
|
+
# @since 1.0.12
|
223
|
+
# @param file [String] The path (relative or absolute) to the file to render
|
224
|
+
# @example
|
225
|
+
# require 'support_readiness'
|
226
|
+
# renderer = Readiness::Client.erb_renderer('temp.erb')
|
227
|
+
# body = renderer.result_with_hash(name: 'Jason')
|
228
|
+
# pp body
|
229
|
+
# # => "\n" + "Hello Jason!\n"
|
230
|
+
def self.erb_renderer(file)
|
231
|
+
ERB.new(File.read(file))
|
232
|
+
end
|
146
233
|
end
|
147
234
|
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Defines the module Readiness.
|
4
|
+
module Readiness
|
5
|
+
##
|
6
|
+
# Defines the class Dates within the module {Readiness}.
|
7
|
+
#
|
8
|
+
# @author Jason Colyer
|
9
|
+
# @since 1.0.12
|
10
|
+
class Dates
|
11
|
+
##
|
12
|
+
# Return the current GitLab quarter as of the current date in format "FY##Q#"
|
13
|
+
#
|
14
|
+
# @return [String]
|
15
|
+
# @example
|
16
|
+
# require 'support_readiness'
|
17
|
+
# pp Readiness::Dates.current_quarter
|
18
|
+
# # => "FY25Q3"
|
19
|
+
def self.current_quarter
|
20
|
+
determine_quarter(Time.now)
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# Return the next GitLab quarter in format "FY##Q#". Defaults to assuming you mean for the current date
|
25
|
+
#
|
26
|
+
# @param date [Various] The date to reference. Can take a String, Date, DateTime, or Time object
|
27
|
+
# @return [String]
|
28
|
+
# @example
|
29
|
+
# require 'support_readiness'
|
30
|
+
# pp Readiness::Dates.next_quarter
|
31
|
+
# # => "FY25Q4"
|
32
|
+
def self.next_quarter(date = Time.now)
|
33
|
+
current = determine_quarter(date)
|
34
|
+
year = current.split('Q').first.split('FY').last.to_i
|
35
|
+
quarter = current.split('Q').last.to_i
|
36
|
+
if quarter == 4
|
37
|
+
"FY#{year + 1}Q1"
|
38
|
+
else
|
39
|
+
"FY#{year}Q#{quarter + 1}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
##
|
44
|
+
# Return the previous GitLab quarter in format "FY##Q#". Defaults to assuming you mean for the current date
|
45
|
+
#
|
46
|
+
# @param date [Various] The date to reference. Can take a String, Date, DateTime, or Time object
|
47
|
+
# @return [String]
|
48
|
+
# @example
|
49
|
+
# require 'support_readiness'
|
50
|
+
# pp Readiness::Dates.next_quarter
|
51
|
+
# # => "FY25Q4"
|
52
|
+
def self.previous_quarter(date = Time.now)
|
53
|
+
current = determine_quarter(date)
|
54
|
+
year = current.split('Q').first.split('FY').last.to_i
|
55
|
+
quarter = current.split('Q').last.to_i
|
56
|
+
if quarter == 1
|
57
|
+
"FY#{year - 1}Q4"
|
58
|
+
else
|
59
|
+
"FY#{year}Q#{quarter - 1}"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
##
|
64
|
+
# Returns the GitLab quarter in format "FY##Q#" from a give date
|
65
|
+
#
|
66
|
+
# @param date [Various] The date to reference. Can take a String, Date, DateTime, or Time object
|
67
|
+
# @return [String]
|
68
|
+
# @example
|
69
|
+
# require 'support_readiness'
|
70
|
+
# pp Readiness::Dates.next_quarter
|
71
|
+
# # => "FY25Q4"
|
72
|
+
def self.determine_quarter(date)
|
73
|
+
date = Time.parse(date) unless [DateTime, Date, Time].include? date.class
|
74
|
+
month = date.month
|
75
|
+
year = date.year.digits(100).first
|
76
|
+
case month
|
77
|
+
when 1
|
78
|
+
"FY#{year}Q4"
|
79
|
+
when 2..4
|
80
|
+
"FY#{year + 1}Q1"
|
81
|
+
when 5..7
|
82
|
+
"FY#{year + 1}Q2"
|
83
|
+
when 8..10
|
84
|
+
"FY#{year + 1}Q3"
|
85
|
+
when 11..12
|
86
|
+
"FY#{year + 1}Q4"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -175,6 +175,41 @@ module Readiness
|
|
175
175
|
end
|
176
176
|
array
|
177
177
|
end
|
178
|
+
|
179
|
+
##
|
180
|
+
# Lists all milestones in a group.
|
181
|
+
# This method can take a long time to run depending on the parameters used.
|
182
|
+
#
|
183
|
+
# @author Jason Colyer
|
184
|
+
# @since 1.0.12
|
185
|
+
# @param client [Object] An instance of {Readiness::GitLab::Client}
|
186
|
+
# @param group [Object] An instance of {Readiness::GitLab::Groups}
|
187
|
+
# @param filters [Array] An array of filter Strings to use. Should be in the format of key=value
|
188
|
+
# @return [Array]
|
189
|
+
# @see https://docs.gitlab.com/ee/api/group_milestones.html#list-group-milestones GitLab API > Groups > Milestones > List group milestones
|
190
|
+
# @example
|
191
|
+
# require 'support_readiness'
|
192
|
+
# config = Readiness::GitLab::Configuration.new
|
193
|
+
# config.token = 'test123abc'
|
194
|
+
# client = Readiness::GitLab::Client.new(config)
|
195
|
+
# group = Readiness::GitLab::Groups.find!(client, 1083469)
|
196
|
+
# milestones = Readiness::GitLab::Groups.milestones(client, project)
|
197
|
+
# pp milestones.count
|
198
|
+
# # => 25
|
199
|
+
def self.milestones(client, group, filters = [])
|
200
|
+
array = []
|
201
|
+
page = 0
|
202
|
+
loop do
|
203
|
+
response = client.connection.get "groups/#{group.id}/milestones?per_page=100&page=#{page}&#{to_param_string(filters)}"
|
204
|
+
handle_request_error(0, 'GitLab', response.status) unless response.status == 200
|
205
|
+
body = Oj.load(response.body)
|
206
|
+
array += body
|
207
|
+
break if body.count < 100
|
208
|
+
|
209
|
+
page += 1
|
210
|
+
end
|
211
|
+
array
|
212
|
+
end
|
178
213
|
end
|
179
214
|
end
|
180
215
|
end
|