gitlab_support_readiness 1.0.38 → 1.0.39

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b1330c4fb2dc431a85de88f941a158751eb98d45431c567669d0913fe8bacd1
4
- data.tar.gz: d40b44310ef4c8217507178164924e83faccf9827d843778a1b71b5562b5e313
3
+ metadata.gz: 435ea0c0bf835de3187a51cba503c25d3a01a33e8654506833beb99ce303861d
4
+ data.tar.gz: 7f0d93630710b1bbc2d3280f917c8272d117101763f5c3ab1b599c3c175f6df1
5
5
  SHA512:
6
- metadata.gz: 2a5ea2c78752e407c81cb86776a1e8d1ee2ac55ee7ebf1acfab7fe4c440c881efac6fcfad72fb1da4d0483c5f31bd8abb663af2d623e13c1387471848e87c445
7
- data.tar.gz: 1635651da9633d04fd6ef1462ed3e5d233f3a0e5c1234bb674df719ed5eef698476b5f6114d9e052e23cadbcb3b56359eec9336fd80209dd4b8c5ac4518ab779
6
+ metadata.gz: f3684cc0b6d09eab8203aca9729260e36f6174dcf9d297eea5e3ce1458f23db053ffba3c9ee93a4bd362ce7e22708e669f49050b93e57a8f7a9b28da49fd1402
7
+ data.tar.gz: 7189ae491dc391e9da253428f3e2b6d559269297dc6f451db6ec1d380d8697be746ec9e692702f7c0c5c51d4649dfda154e9a3e59058362117a87cb538dd34a6
@@ -0,0 +1,59 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Defines the module Readiness.
4
+ module Readiness
5
+ ##
6
+ # Defines the module GoogleSheets
7
+ module GoogleSheets
8
+ ##
9
+ # Defines the class Client within the module {Readiness::GoogleSheets}.
10
+ #
11
+ # @author Jason Colyer
12
+ # @since 1.0.39
13
+ class Client
14
+ attr_accessor :spreadsheet_id, :service
15
+
16
+ ##
17
+ # Creates a new {Readiness::GoogleSheets::Client} instance
18
+ #
19
+ # @author Jason Colyer
20
+ # @since 1.0.39
21
+ # @param config [Object] An instance of {Readiness::GoogleSheets::Configuration}
22
+ # @example
23
+ # require 'support_readiness'
24
+ # config = Readiness::GoogleSheets::Configuration.new
25
+ # config.spreadsheet_id = 'abc123'
26
+ # config.filepath = 'data/config.json'
27
+ # client = Readiness::GoogleSheets::Client.new(config)
28
+ # pp client.spreadsheet_id
29
+ # # => "abc123"
30
+ def initialize(config = Readiness::GoogleSheets::Configuration.new)
31
+ @service = generate_service(config)
32
+ @spreadsheet_id = config.spreadsheet_id
33
+ end
34
+
35
+ ##
36
+ # Generates a service connection to Google Calendar
37
+ #
38
+ # @author Jason Colyer
39
+ # @since 1.0.39
40
+ # @param config [Object] An instance of {Readiness::GoogleSheets::Configuration}
41
+ # @example
42
+ # require 'support_readiness'
43
+ # config = Readiness::GoogleSheets::Configuration.new
44
+ # config.spreadsheet_id = 'abc123'
45
+ # config.filepath = 'data/config.json'
46
+ # service = Readiness::GoogleSheets::Client.generate_service(config)
47
+ def generate_service(config)
48
+ authorize = Google::Auth::ServiceAccountCredentials.make_creds(
49
+ json_key_io: File.open(config.filepath),
50
+ scope: config.scope
51
+ )
52
+ authorize.fetch_access_token!
53
+ service = Google::Apis::SheetsV4::SheetsService.new
54
+ service.authorization = authorize
55
+ service
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Defines the module Readiness.
4
+ module Readiness
5
+ ##
6
+ # Defines the module GoogleSheets
7
+ module GoogleSheets
8
+ ##
9
+ # Defines the class Configuration within the module {Readiness::GoogleCalendar}.
10
+ #
11
+ # @author Jason Colyer
12
+ # @since 1.0.39
13
+ class Configuration
14
+ attr_accessor :spreadsheet_id, :filepath, :scope
15
+
16
+ ##
17
+ # Creates a new {Readiness::GoogleSheets::Configuration} instance
18
+ #
19
+ # @author Jason Colyer
20
+ # @since 1.0.39
21
+ # @example
22
+ # require 'support_readiness'
23
+ # config = Readiness::GoogleSheets::Configuration.new
24
+ # config.spreadsheet_id = 'abc123'
25
+ # config.filepath = 'data/config.json'
26
+ # pp config
27
+ # # => #<Readiness::GoogleSheets::Configuration:0x00007f352fdd1420
28
+ # @spreadsheet_id="abc123"
29
+ # @filepath="data/config.json"
30
+ # @scope="https://www.googleapis.com/auth/spreadsheets">
31
+ def initialize
32
+ # /home/jason/dev/gitlab-support-readiness/zendesk-us-government/tickets/round-robin/lib/round_robin
33
+ @spreadsheet_id = ''
34
+ @filepath = ''
35
+ @scope = 'https://www.googleapis.com/auth/spreadsheets'
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,123 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Defines the module Readiness.
4
+ module Readiness
5
+ ##
6
+ # Defines the module GoogleSheets
7
+ module GoogleSheets
8
+ ##
9
+ # Defines the class Spreadsheets within the module {Readiness::GoogleSheets}.
10
+ #
11
+ # @author Jason Colyer
12
+ # @since 1.0.39
13
+ class Spreadsheets < Readiness::Client
14
+ ##
15
+ # Gets spreadsheet information
16
+ #
17
+ # @author Jason Colyer
18
+ # @since 1.0.39
19
+ # @param client [Object] An instance of {Readiness::GoogleSheets::Client}
20
+ # @example
21
+ # require 'support_readiness'
22
+ # config = Readiness::GoogleSheets::Configuration.new
23
+ # config.spreadsheet_id = 'abc123'
24
+ # config.filepath = 'data/config.json'
25
+ # client = Readiness::GoogleSheets::Client.new(config)
26
+ # spreadsheet = Readiness::GoogleSheets::Spreadsheets.get_info(client)
27
+ # pp spreadsheet.properties.title
28
+ # # => "Jason Test"
29
+ def self.get_info(client)
30
+ client.service.get_spreadsheet(client.spreadsheet_id)
31
+ end
32
+
33
+ ##
34
+ # Gets a list of spreadsheet sheets
35
+ #
36
+ # @author Jason Colyer
37
+ # @since 1.0.39
38
+ # @param spreadsheet [Object] The spreadsheet to use
39
+ # @example
40
+ # require 'support_readiness'
41
+ # config = Readiness::GoogleSheets::Configuration.new
42
+ # config.spreadsheet_id = 'abc123'
43
+ # config.filepath = 'data/config.json'
44
+ # client = Readiness::GoogleSheets::Client.new(config)
45
+ # spreadsheet = Readiness::GoogleSheets::Spreadsheets.get_info(client)
46
+ # pp Readiness::GoogleSheets::Spreadsheets.sheets(spreadsheet)
47
+ # # => ["Sheet1", "Sheet2"]
48
+ def self.sheets(spreadsheet)
49
+ spreadsheet.sheets.map { |s| s.properties.title }
50
+ end
51
+
52
+ ##
53
+ # Gets data within a spreadsheet
54
+ #
55
+ # @author Jason Colyer
56
+ # @since 1.0.39
57
+ # @param client [Object] An instance of {Readiness::GoogleSheets::Client}
58
+ # @param range [String] A Google Sheets range
59
+ # @example
60
+ # require 'support_readiness'
61
+ # config = Readiness::GoogleSheets::Configuration.new
62
+ # config.spreadsheet_id = 'abc123'
63
+ # config.filepath = 'data/config.json'
64
+ # client = Readiness::GoogleSheets::Client.new(config)
65
+ # data = Readiness::GoogleSheets::Spreadsheets.data(client, 'A1:A3')
66
+ # pp data.values.first
67
+ # # => ["Test 1", "Test 2"]
68
+ def self.data(client, range)
69
+ client.service.get_spreadsheet_values(client.spreadsheet_id, range)
70
+ end
71
+
72
+ ##
73
+ # Appends data to a spreadsheet
74
+ #
75
+ # @author Jason Colyer
76
+ # @since 1.0.39
77
+ # @param client [Object] An instance of {Readiness::GoogleSheets::Client}
78
+ # @param range [String] A Google Sheets range
79
+ # @param values[Array] An Array of Arrays for the values to use
80
+ # @example
81
+ # require 'support_readiness'
82
+ # config = Readiness::GoogleSheets::Configuration.new
83
+ # config.spreadsheet_id = 'abc123'
84
+ # config.filepath = 'data/config.json'
85
+ # client = Readiness::GoogleSheets::Client.new(config)
86
+ # values = [
87
+ # ['Tickets 2024-10', 125],
88
+ # ['Agents 2024-10', 150],
89
+ # ['SSAT 2024-10', '95%']
90
+ # ]
91
+ # Readiness::GoogleSheets::Spreadsheets.append_data(client, 'Ticket Data!A1:A3', values)
92
+ def self.append_data(client, range, values)
93
+ value_range = Google::Apis::SheetsV4::ValueRange.new(values: values)
94
+ client.service.append_spreadsheet_value(client.spreadsheet_id, range, value_range, value_input_option: 'RAW')
95
+ end
96
+
97
+ ##
98
+ # Updates data in a spreadsheet
99
+ #
100
+ # @author Jason Colyer
101
+ # @since 1.0.39
102
+ # @param client [Object] An instance of {Readiness::GoogleSheets::Client}
103
+ # @param range [String] A Google Sheets range
104
+ # @param values[Array] An Array of Arrays for the values to use
105
+ # @example
106
+ # require 'support_readiness'
107
+ # config = Readiness::GoogleSheets::Configuration.new
108
+ # config.spreadsheet_id = 'abc123'
109
+ # config.filepath = 'data/config.json'
110
+ # client = Readiness::GoogleSheets::Client.new(config)
111
+ # values = [
112
+ # ['Tickets 2024-10', 125],
113
+ # ['Agents 2024-10', 150],
114
+ # ['SSAT 2024-10', '95%']
115
+ # ]
116
+ # Readiness::GoogleSheets::Spreadsheets.update_data(client, 'Ticket Data!A1:A3', values)
117
+ def self.update_data(client, range, values)
118
+ value_range = Google::Apis::SheetsV4::ValueRange.new(values: values)
119
+ client.service.update_spreadsheet_value(client.spreadsheet_id, range, value_range, value_input_option: 'RAW')
120
+ end
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Defines the module Readiness.
4
+ module Readiness
5
+ ##
6
+ # Defines the module GoogleSheets
7
+ # @author Jason Colyer
8
+ # @since 1.0.39
9
+ module GoogleSheets
10
+ require "#{__dir__}/google_sheets/client"
11
+ require "#{__dir__}/google_sheets/configuration"
12
+ require "#{__dir__}/google_sheets/spreadsheets"
13
+ end
14
+ end
@@ -18,6 +18,7 @@ require 'faraday'
18
18
  require 'faraday/multipart'
19
19
  require 'faraday/retry'
20
20
  require 'google/apis/calendar_v3'
21
+ require 'google/apis/sheets_v4'
21
22
  require 'json'
22
23
  require 'nokogiri'
23
24
  require 'oj'
@@ -34,6 +35,7 @@ require "#{__dir__}/support_readiness/calendly"
34
35
  require "#{__dir__}/support_readiness/dates"
35
36
  require "#{__dir__}/support_readiness/gitlab"
36
37
  require "#{__dir__}/support_readiness/google_calendar"
38
+ require "#{__dir__}/support_readiness/google_sheets"
37
39
  require "#{__dir__}/support_readiness/mailgun"
38
40
  require "#{__dir__}/support_readiness/pagerduty"
39
41
  require "#{__dir__}/support_readiness/redis"
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.38
4
+ version: 1.0.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Colyer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-01 00:00:00.000000000 Z
11
+ date: 2024-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 0.3.6
39
+ version: 0.4.1
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: 0.3.6
46
+ version: 0.4.1
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: digest
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -128,6 +128,20 @@ dependencies:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
130
  version: 0.43.0
131
+ - !ruby/object:Gem::Dependency
132
+ name: google-apis-sheets_v4
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: 0.38.0
138
+ type: :runtime
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: 0.38.0
131
145
  - !ruby/object:Gem::Dependency
132
146
  name: json
133
147
  requirement: !ruby/object:Gem::Requirement
@@ -258,6 +272,10 @@ files:
258
272
  - lib/support_readiness/google_calendar/client.rb
259
273
  - lib/support_readiness/google_calendar/configuration.rb
260
274
  - lib/support_readiness/google_calendar/events.rb
275
+ - lib/support_readiness/google_sheets.rb
276
+ - lib/support_readiness/google_sheets/client.rb
277
+ - lib/support_readiness/google_sheets/configuration.rb
278
+ - lib/support_readiness/google_sheets/spreadsheets.rb
261
279
  - lib/support_readiness/mailgun.rb
262
280
  - lib/support_readiness/mailgun/bounces.rb
263
281
  - lib/support_readiness/mailgun/client.rb