gitlab_support_readiness 1.0.124 → 1.0.125
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77742079ee62db6c4f2ed4dce4642ea2bf2fa06e3fd473d9cbe99e81e0f3bfae
|
4
|
+
data.tar.gz: 5756f05d4e08901351b13bb437c8681cc4c88267f653c28ff57d509c3cc468ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2929642f4896b0c56d0edfc3c48464a0aa0da419cd6fd94cedd6bb64f8bcca8e2672fa41e61d8c37e0b700e9e91cd025474394508929fc1e09ff13a9f681df75
|
7
|
+
data.tar.gz: cdafbe5d734f4ad9e5eee5fe82593dfc46041884f3bf41665461652c635185ace3ee2346fb0065d6d4d0cee292711aee7db8551c31d330100bedd7ccd9debe96
|
@@ -0,0 +1,156 @@
|
|
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 OAuthClients within the module {Readiness::Zendesk}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.125
|
12
|
+
# @todo create - https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_clients/#create-client
|
13
|
+
# @todo update - https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_clients/#update-client
|
14
|
+
# @todo delete - https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_clients/#delete-client
|
15
|
+
# @todo generate secret - https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_clients/#delete-client
|
16
|
+
class OAuthClients < Readiness::Client
|
17
|
+
attr_accessor :company, :created_at, :description, :id, :identifier, :name, :redirect_uri, :secret, :unique_id, :updated_at, :user_id
|
18
|
+
|
19
|
+
##
|
20
|
+
# Creates a new {Readiness::Zendesk::OAuthClients} instance
|
21
|
+
#
|
22
|
+
# @author Jason Colyer
|
23
|
+
# @since 1.0.125
|
24
|
+
# @param object [Object] An instance of {Readiness::Zendesk::OAuthClients}
|
25
|
+
# @example
|
26
|
+
# require 'support_readiness'
|
27
|
+
# Readiness::Zendesk::OAuthClients.new
|
28
|
+
def initialize(object = {})
|
29
|
+
@company = object['company']
|
30
|
+
@created_at = object['created_at']
|
31
|
+
@description = object['description']
|
32
|
+
@id = object['id']
|
33
|
+
@identifier = object['identifier']
|
34
|
+
@name = object['name']
|
35
|
+
@redirect_uri = object['redirect_uri']
|
36
|
+
@secret = object['secret']
|
37
|
+
@unique_id = object['unique_id']
|
38
|
+
@updated_at = object['updated_at']
|
39
|
+
@user_id = object['user_id']
|
40
|
+
end
|
41
|
+
|
42
|
+
##
|
43
|
+
# Lists all OAuth clients.
|
44
|
+
#
|
45
|
+
# @author Jason Colyer
|
46
|
+
# @since 1.0.125
|
47
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
48
|
+
# @return [Array]
|
49
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_clients/#list-clients Zendesk API > OAuth Clients > List Clients
|
50
|
+
# @example
|
51
|
+
# require 'support_readiness'
|
52
|
+
# config = Readiness::Zendesk::Configuration.new
|
53
|
+
# config.username = 'alice@example.com'
|
54
|
+
# config.token = 'test123abc'
|
55
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
56
|
+
# client = Readiness::Zendesk::Client.new(config)
|
57
|
+
# oauth_clients = Readiness::Zendesk::OAuthClients.list(client)
|
58
|
+
# pp oauth_clients.count
|
59
|
+
# # => 12
|
60
|
+
def self.list(client)
|
61
|
+
array = []
|
62
|
+
opts = 'page[size]=100'
|
63
|
+
loop do
|
64
|
+
response = client.connection.get("oauth/clients?#{opts}")
|
65
|
+
handle_request_error(0, 'Zendesk', response.status) unless response.status == 200
|
66
|
+
body = Oj.load(response.body)
|
67
|
+
array += body['clients'].map { |c| OAuthClients.new(c) }
|
68
|
+
break unless body['meta']['has_more']
|
69
|
+
|
70
|
+
opts = body['links']['next'].split('?').last
|
71
|
+
end
|
72
|
+
array
|
73
|
+
end
|
74
|
+
|
75
|
+
##
|
76
|
+
# Locates an OAuth client within Zendesk. This will not exit on error (except Authentication errors)
|
77
|
+
#
|
78
|
+
# @author Jason Colyer
|
79
|
+
# @since 1.0.125
|
80
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
81
|
+
# @param cid [Integer[ The OAuth client ID to find
|
82
|
+
# @param return [Hash]
|
83
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_clients/#show-client Zendesk API > OAuth Clients > Show Client
|
84
|
+
# @example
|
85
|
+
# require 'support_readiness'
|
86
|
+
# config = Readiness::Zendesk::Configuration.new
|
87
|
+
# config.username = 'alice@example.com'
|
88
|
+
# config.token = 'test123abc'
|
89
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
90
|
+
# client = Readiness::Zendesk::Client.new(config)
|
91
|
+
# oauth_client = Readiness::Zendesk::OAuthClients.find(client, 223443)
|
92
|
+
# pp oauth_client.name
|
93
|
+
# # => "Test Client"
|
94
|
+
def self.find(client, cid)
|
95
|
+
response = client.connection.get("oauth/clients/#{cid}")
|
96
|
+
handle_request_error(0, 'Zendesk', response.status, { action: 'get', id: cid }) unless response.status == 200
|
97
|
+
return OAuthClients.new(Oj.load(response.body)['client']) if response.status == 200
|
98
|
+
|
99
|
+
Oj.load(response.body)
|
100
|
+
end
|
101
|
+
|
102
|
+
##
|
103
|
+
# Locates an OAuth client within Zendesk. This will exit on error
|
104
|
+
#
|
105
|
+
# @author Jason Colyer
|
106
|
+
# @since 1.0.125
|
107
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
108
|
+
# @param cid [Integer[ The OAuth client ID to find
|
109
|
+
# @param return [Hash]
|
110
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_clients/#show-client Zendesk API > OAuth Clients > Show Client
|
111
|
+
# @example
|
112
|
+
# require 'support_readiness'
|
113
|
+
# config = Readiness::Zendesk::Configuration.new
|
114
|
+
# config.username = 'alice@example.com'
|
115
|
+
# config.token = 'test123abc'
|
116
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
117
|
+
# client = Readiness::Zendesk::Client.new(config)
|
118
|
+
# oauth_client = Readiness::Zendesk::OAuthClients.find!(client, 223443)
|
119
|
+
# pp oauth_client.name
|
120
|
+
# # => "Test Client"
|
121
|
+
def self.find!(client, cid)
|
122
|
+
response = client.connection.get("oauth/clients/#{cid}")
|
123
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Find OAuth client', id: cid }) unless response.status == 200
|
124
|
+
OAuthClients.new(Oj.load(response.body)['client'])
|
125
|
+
end
|
126
|
+
|
127
|
+
##
|
128
|
+
# Locates an OAuth client within Zendesk by name. Can utilize a cache for quicker results
|
129
|
+
#
|
130
|
+
# @author Jason Colyer
|
131
|
+
# @since 1.0.125
|
132
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
133
|
+
# @param name [String] The OAuth client name to look for
|
134
|
+
# @param cache [Array] The results of {Readiness::Zendesk::OAuthClients#list}
|
135
|
+
# @return [Object] An instance of {Readiness::Zendesk::OAuthClients}
|
136
|
+
# @example
|
137
|
+
# require 'support_readiness'
|
138
|
+
# config = Readiness::Zendesk::Configuration.new
|
139
|
+
# config.username = 'alice@example.com'
|
140
|
+
# config.token = 'test123abc'
|
141
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
142
|
+
# client = Readiness::Zendesk::Client.new(config)
|
143
|
+
# oauth_client = Readiness::Zendesk::OAuthClients.find_by_name(client, 'Test Client')
|
144
|
+
# pp oauth_client.id
|
145
|
+
# # => 223443
|
146
|
+
def self.find_by_name(client, name, cache = nil)
|
147
|
+
oauth_clients = if cache.nil?
|
148
|
+
OAuthClients.list(client)
|
149
|
+
else
|
150
|
+
cache
|
151
|
+
end
|
152
|
+
oauth_clients.detect { |o| o.name == name }
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
@@ -0,0 +1,74 @@
|
|
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 OAuthTokens within the module {Readiness::Zendesk}.
|
9
|
+
#
|
10
|
+
# @author Jason Colyer
|
11
|
+
# @since 1.0.125
|
12
|
+
# @todo list - https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_tokens/#list-tokens
|
13
|
+
# @todo show - https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_tokens/#show-token
|
14
|
+
# @todo revoke - https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_tokens/#revoke-token
|
15
|
+
class OAuthTokens < Readiness::Client
|
16
|
+
attr_accessor :client_id, :created_at, :expires_at, :full_token, :id, :refresh_token, :refresh_token_expires_at, :scopes, :token, :used_at, :user_id
|
17
|
+
|
18
|
+
##
|
19
|
+
# Creates a new {Readiness::Zendesk::OAuthTokens} instance
|
20
|
+
#
|
21
|
+
# @author Jason Colyer
|
22
|
+
# @since 1.0.125
|
23
|
+
# @param object [Object] An instance of {Readiness::Zendesk::OAuthTokens}
|
24
|
+
# @example
|
25
|
+
# require 'support_readiness'
|
26
|
+
# Readiness::Zendesk::OAuthTokens.new
|
27
|
+
def initialize(object = {})
|
28
|
+
@client_id = object['client_id']
|
29
|
+
@created_at = object['created_at']
|
30
|
+
@expires_at = object['expires_at']
|
31
|
+
@full_token = object['full_token']
|
32
|
+
@id = object['id']
|
33
|
+
@refresh_token = object['refresh_token']
|
34
|
+
@refresh_token_expires_at = object['refresh_token_expires_at']
|
35
|
+
@scopes = object['scopes']
|
36
|
+
@token = object['token']
|
37
|
+
@used_at = object['used_at']
|
38
|
+
@user_id = object['user_id']
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# Creates an Oauth token. Will exit if unsuccessful.
|
43
|
+
#
|
44
|
+
# @author Jason Colyer
|
45
|
+
# @since 1.0.125
|
46
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
47
|
+
# @param token [Object] An instance of {Readiness::Zendesk::OAuthTokens}
|
48
|
+
# @return [Object] An instance of {Readiness::Zendesk::OAuthTokens}
|
49
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/oauth/oauth_tokens/#create-token Zendesk API > OAuth Tokens > Create Token
|
50
|
+
# @example
|
51
|
+
# require 'support_readiness'
|
52
|
+
# config = Readiness::Zendesk::Configuration.new
|
53
|
+
# config.username = 'alice@example.com'
|
54
|
+
# config.token = 'test123abc'
|
55
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
56
|
+
# client = Readiness::Zendesk::Client.new(config)
|
57
|
+
# token = Readiness::Zendesk::OAuthTokens.new
|
58
|
+
# token.client_id = 1234
|
59
|
+
# token.scopes = [
|
60
|
+
# 'impersonate',
|
61
|
+
# 'write'
|
62
|
+
# ]
|
63
|
+
# create = Readiness::Zendesk::OAuthTokens.create!(client, token)
|
64
|
+
# pp create.full_token
|
65
|
+
# # => "4v8AR9vXCM7dV4murXlIaBAAzDrAw9lIbaHF7X9VbVPtOABAyy3dnTtHE3A6AdNC"
|
66
|
+
def self.create!(client, token)
|
67
|
+
pp to_clean_json_with_key(token, 'token')
|
68
|
+
response = client.connection.post 'oauth/tokens', to_clean_json_with_key(token, 'token')
|
69
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Create Oauth token', message: Oj.load(response.body)}) unless response.status == 201
|
70
|
+
OAuthTokens.new(Oj.load(response.body)['token'])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -927,6 +927,58 @@ module Readiness
|
|
927
927
|
end
|
928
928
|
true
|
929
929
|
end
|
930
|
+
|
931
|
+
##
|
932
|
+
# Add a satisfaction rating to a ticket (must be done using end-user as the config.username). Will exit if unsuccessful
|
933
|
+
#
|
934
|
+
# @author Jason Colyer
|
935
|
+
# @since NEW_VERSION
|
936
|
+
# @param client [Object] An instance of {Readiness::Zendesk::Client}
|
937
|
+
# @param ticket [Object] An instance of {Readiness::Zendesk::Tickets}
|
938
|
+
# @param score [String] The score to use ('good' or 'bad' is the normal usage)
|
939
|
+
# @param comment [String] The comment to use
|
940
|
+
# @return [Hash]
|
941
|
+
# @see https://developer.zendesk.com/api-reference/ticketing/ticket-management/satisfaction_ratings/#create-a-satisfaction-rating Zendesk API > Satisfaction Ratings > Create a Satisfaction Rating
|
942
|
+
# @example
|
943
|
+
# require 'support_readiness'
|
944
|
+
# config = Readiness::Zendesk::Configuration.new
|
945
|
+
# config.username = 'alice@example.com'
|
946
|
+
# config.token = 'test123abc'
|
947
|
+
# config.url = 'https://example.zendesk.com/api/v2'
|
948
|
+
# client = Readiness::Zendesk::Client.new(config)
|
949
|
+
# ticket = Readiness::Zendesk::Tickets.find!(client, 141)
|
950
|
+
# user = Readiness::Zendesk::Users.find!(client, 123456)
|
951
|
+
# oauth_client = Readiness::Zendesk::OAuthClients.find_by_name(client, 'Test App')
|
952
|
+
# new_token = Readiness::Zendesk::OAuthTokens.new
|
953
|
+
# new_token.client_id = oauth_client.id
|
954
|
+
# new_token.scopes = [
|
955
|
+
# 'impersonate',
|
956
|
+
# 'write'
|
957
|
+
# ]
|
958
|
+
# oauth_token = Readiness::Zendesk::OAuthTokens.create!(client, new_token)
|
959
|
+
# user_client = Faraday.new(client.url) do |c|
|
960
|
+
# c.request :retry, {
|
961
|
+
# max: client.retry_max,
|
962
|
+
# interval: sb_zendesk_config.retry_interval,
|
963
|
+
# interval_randomness: client.retry_randomness,
|
964
|
+
# backoff_factor: client.retry_backoff,
|
965
|
+
# exceptions: client.retry_exceptions
|
966
|
+
# }
|
967
|
+
# c.adapter Faraday.default_adapter
|
968
|
+
# c.headers['Content-Type'] = 'application/json'
|
969
|
+
# c.headers['Authorization'] = "Bearer #{oauth_token.full_token}"
|
970
|
+
# c.headers['X-On-Behalf-Of'] = user.email
|
971
|
+
# end
|
972
|
+
# rating = Readiness::Zendesk::Tickets.create_satisfaction_score!(user_client, ticket, 'good', 'jason is awesome!')
|
973
|
+
# pp rating['score']
|
974
|
+
# # => "good"
|
975
|
+
def self.create_satisfaction_score!(client, ticket, score, comment)
|
976
|
+
data = { satisfaction_rating: { score: score, comment: comment }}.to_json
|
977
|
+
response = client.post "tickets/#{ticket.id}/satisfaction_rating", data
|
978
|
+
pp response.body
|
979
|
+
handle_request_error(1, 'Zendesk', response.status, { action: 'Add satisfaction rating', message: Oj.load(response.body)}) unless response.status == 200
|
980
|
+
Oj.load(response.body)['satisfaction_rating']
|
981
|
+
end
|
930
982
|
end
|
931
983
|
end
|
932
984
|
end
|
@@ -21,6 +21,8 @@ module Readiness
|
|
21
21
|
require "#{__dir__}/zendesk/job_statuses"
|
22
22
|
require "#{__dir__}/zendesk/locales"
|
23
23
|
require "#{__dir__}/zendesk/macros"
|
24
|
+
require "#{__dir__}/zendesk/oauth_clients"
|
25
|
+
require "#{__dir__}/zendesk/oauth_tokens"
|
24
26
|
require "#{__dir__}/zendesk/organization_fields"
|
25
27
|
require "#{__dir__}/zendesk/organization_memberships"
|
26
28
|
require "#{__dir__}/zendesk/organizations"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab_support_readiness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.125
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Colyer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-02-
|
11
|
+
date: 2025-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -418,6 +418,8 @@ files:
|
|
418
418
|
- lib/support_readiness/zendesk/job_statuses.rb
|
419
419
|
- lib/support_readiness/zendesk/locales.rb
|
420
420
|
- lib/support_readiness/zendesk/macros.rb
|
421
|
+
- lib/support_readiness/zendesk/oauth_clients.rb
|
422
|
+
- lib/support_readiness/zendesk/oauth_tokens.rb
|
421
423
|
- lib/support_readiness/zendesk/organization_fields.rb
|
422
424
|
- lib/support_readiness/zendesk/organization_memberships.rb
|
423
425
|
- lib/support_readiness/zendesk/organizations.rb
|