defra_ruby_storm 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ad0b971a9d91168670b5ac477ba3cbf7e61e1f963524cbc6a3a709fd57c45d2b
4
+ data.tar.gz: eeead0895c42b10efdb8f2be806163efff6e3431ed7ef91b4239ff50e0d23064
5
+ SHA512:
6
+ metadata.gz: '090b13c85ec48593bfa9b62a82ee63c79ca25ee8df199532d6e20efdc85ea4d2f03ac5bdb1f57d9e495c5ed467e7a2f70aa1bfbfaa87c2e6962cfa561b8d8cd2'
7
+ data.tar.gz: 48e799563c26871b7a9be8541509adc5cc9adbe865783c086414973d8047d010be5cfe29ca8a0af410b9b30ad159819536cf57ef337bf081931d9811fd3900f5
@@ -0,0 +1,8 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
8
+ versioning-strategy: lockfile-only
@@ -0,0 +1,43 @@
1
+ name: CI
2
+
3
+ on: push
4
+
5
+ jobs:
6
+ build:
7
+ # You must use a Linux environment when using service containers or container jobs
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ # Downloads a copy of the code in your repository before running CI tests
12
+ - name: Checkout repository
13
+ uses: actions/checkout@v2
14
+ with:
15
+ fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of sonarcloud analysis
16
+
17
+ # We don't have to specify the ruby version, or grab it from .ruby-verion. This action supports reading the
18
+ # version from .ruby-verion itself
19
+ - name: Install Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
23
+
24
+ # Run linting first. No point running the tests if there is a linting issue
25
+ - name: Run lint check
26
+ run: |
27
+ bundle exec rubocop --format progress --format json --out rubocop-result.json
28
+
29
+ # This includes an extra run step. The sonarcloud analysis will be run in a docker container with the current
30
+ # folder mounted as `/github/workspace`. The problem is when the coverage.json file is generated it will
31
+ # reference the code in the current folder. So to enable sonarcloud to matchup code coverage with the files we use
32
+ # sed to update the references in coverage.json
33
+ # https://community.sonarsource.com/t/code-coverage-doesnt-work-with-github-action/16747/6
34
+ - name: Run unit tests
35
+ run: |
36
+ bundle exec rspec
37
+ sed -i 's/\/home\/runner\/work\/defra-ruby-storm\/defra-ruby-storm\//\/github\/workspace\//g' coverage/coverage.json
38
+
39
+ - name: Analyze with SonarCloud
40
+ uses: sonarsource/sonarcloud-github-action@master
41
+ env:
42
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This is provided automatically by GitHub
43
+ SONAR_TOKEN: ${{ secrets.RUBY_SONAR_TOKEN }} # This needs to be set in your repo; settings -> secrets
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+ # simplecov https://github.com/colszowka/simplecov
14
+ coverage
15
+
16
+ .env
17
+ .env.local
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,3 @@
1
+ inherit_gem:
2
+ defra_ruby_style:
3
+ - default.yml
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-3.2.2
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-10-26
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in defra_ruby_storm.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+ gem "rubocop-rspec"
12
+
13
+ gem "rubocop", "~> 1.21"
14
+
15
+ gem "webmock", "~> 3.4"
16
+
17
+ gem "defra_ruby_style", "~> 0.4.0"
18
+
19
+ gem "simplecov", "~> 0.22.0", require: false
data/Gemfile.lock ADDED
@@ -0,0 +1,144 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ defra_ruby_storm (0.1.0)
5
+ savon (~> 2.13.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.8.5)
11
+ public_suffix (>= 2.0.2, < 6.0)
12
+ akami (1.3.1)
13
+ gyoku (>= 0.4.0)
14
+ nokogiri
15
+ ast (2.4.2)
16
+ builder (3.2.4)
17
+ crack (0.4.5)
18
+ rexml
19
+ date (3.3.3)
20
+ defra_ruby_style (0.4.0)
21
+ rubocop (>= 1.0, < 2.0)
22
+ rubocop-factory_bot
23
+ rubocop-rake
24
+ rubocop-rspec
25
+ diff-lcs (1.5.0)
26
+ docile (1.4.0)
27
+ gyoku (1.4.0)
28
+ builder (>= 2.1.2)
29
+ rexml (~> 3.0)
30
+ hashdiff (1.0.1)
31
+ httpi (3.0.1)
32
+ rack
33
+ json (2.6.3)
34
+ language_server-protocol (3.17.0.3)
35
+ mail (2.8.1)
36
+ mini_mime (>= 0.1.1)
37
+ net-imap
38
+ net-pop
39
+ net-smtp
40
+ mini_mime (1.1.5)
41
+ net-imap (0.4.3)
42
+ date
43
+ net-protocol
44
+ net-pop (0.1.2)
45
+ net-protocol
46
+ net-protocol (0.2.1)
47
+ timeout
48
+ net-smtp (0.4.0)
49
+ net-protocol
50
+ nokogiri (1.15.4-x86_64-darwin)
51
+ racc (~> 1.4)
52
+ nokogiri (1.15.4-x86_64-linux)
53
+ racc (~> 1.4)
54
+ nori (2.6.0)
55
+ parallel (1.23.0)
56
+ parser (3.2.2.4)
57
+ ast (~> 2.4.1)
58
+ racc
59
+ public_suffix (5.0.3)
60
+ racc (1.7.2)
61
+ rack (3.0.8)
62
+ rainbow (3.1.1)
63
+ rake (13.1.0)
64
+ regexp_parser (2.8.2)
65
+ rexml (3.2.6)
66
+ rspec (3.12.0)
67
+ rspec-core (~> 3.12.0)
68
+ rspec-expectations (~> 3.12.0)
69
+ rspec-mocks (~> 3.12.0)
70
+ rspec-core (3.12.2)
71
+ rspec-support (~> 3.12.0)
72
+ rspec-expectations (3.12.3)
73
+ diff-lcs (>= 1.2.0, < 2.0)
74
+ rspec-support (~> 3.12.0)
75
+ rspec-mocks (3.12.6)
76
+ diff-lcs (>= 1.2.0, < 2.0)
77
+ rspec-support (~> 3.12.0)
78
+ rspec-support (3.12.1)
79
+ rubocop (1.57.2)
80
+ json (~> 2.3)
81
+ language_server-protocol (>= 3.17.0)
82
+ parallel (~> 1.10)
83
+ parser (>= 3.2.2.4)
84
+ rainbow (>= 2.2.2, < 4.0)
85
+ regexp_parser (>= 1.8, < 3.0)
86
+ rexml (>= 3.2.5, < 4.0)
87
+ rubocop-ast (>= 1.28.1, < 2.0)
88
+ ruby-progressbar (~> 1.7)
89
+ unicode-display_width (>= 2.4.0, < 3.0)
90
+ rubocop-ast (1.30.0)
91
+ parser (>= 3.2.1.0)
92
+ rubocop-capybara (2.19.0)
93
+ rubocop (~> 1.41)
94
+ rubocop-factory_bot (2.24.0)
95
+ rubocop (~> 1.33)
96
+ rubocop-rake (0.6.0)
97
+ rubocop (~> 1.0)
98
+ rubocop-rspec (2.25.0)
99
+ rubocop (~> 1.40)
100
+ rubocop-capybara (~> 2.17)
101
+ rubocop-factory_bot (~> 2.22)
102
+ ruby-progressbar (1.13.0)
103
+ savon (2.13.1)
104
+ akami (~> 1.2)
105
+ builder (>= 2.1.2)
106
+ gyoku (~> 1.2)
107
+ httpi (>= 2.4.5)
108
+ mail (~> 2.5)
109
+ nokogiri (>= 1.8.1)
110
+ nori (~> 2.4)
111
+ wasabi (~> 3.4)
112
+ simplecov (0.22.0)
113
+ docile (~> 1.1)
114
+ simplecov-html (~> 0.11)
115
+ simplecov_json_formatter (~> 0.1)
116
+ simplecov-html (0.12.3)
117
+ simplecov_json_formatter (0.1.4)
118
+ timeout (0.4.0)
119
+ unicode-display_width (2.5.0)
120
+ wasabi (3.8.0)
121
+ addressable
122
+ httpi (~> 3.0)
123
+ nokogiri (>= 1.4.2)
124
+ webmock (3.19.1)
125
+ addressable (>= 2.8.0)
126
+ crack (>= 0.3.2)
127
+ hashdiff (>= 0.4.0, < 2.0.0)
128
+
129
+ PLATFORMS
130
+ x86_64-darwin-22
131
+ x86_64-linux
132
+
133
+ DEPENDENCIES
134
+ defra_ruby_storm!
135
+ defra_ruby_style (~> 0.4.0)
136
+ rake (~> 13.0)
137
+ rspec (~> 3.0)
138
+ rubocop (~> 1.21)
139
+ rubocop-rspec
140
+ simplecov (~> 0.22.0)
141
+ webmock (~> 3.4)
142
+
143
+ BUNDLED WITH
144
+ 2.4.12
data/LICENSE ADDED
@@ -0,0 +1,8 @@
1
+ The Open Government Licence (OGL) Version 3
2
+
3
+ Copyright (c) 2023 Defra
4
+
5
+ This source code is licensed under the Open Government Licence v3.0. To view this
6
+ licence, visit www.nationalarchives.gov.uk/doc/open-government-licence/version/3
7
+ or write to the Information Policy Team, The National Archives, Kew, Richmond,
8
+ Surrey, TW9 4DU.
data/README.md ADDED
@@ -0,0 +1,125 @@
1
+ # DefraRuby::Storm
2
+
3
+ ![Build Status](https://github.com/DEFRA/defra-ruby-storm/workflows/CI/badge.svg)
4
+ [![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=DEFRA_defra-ruby-storm&metric=sqale_rating)](https://sonarcloud.io/dashboard?id=DEFRA_defra-ruby-storm)
5
+ [![Coverage](https://sonarcloud.io/api/project_badges/measure?project=DEFRA_defra-ruby-storm&metric=coverage)](https://sonarcloud.io/dashboard?id=DEFRA_defra-ruby-storm)
6
+ [![Gem Version](https://badge.fury.io/rb/defra_ruby_storm.svg)](https://badge.fury.io/rb/defra_ruby_storm)
7
+ [![Licence](https://img.shields.io/badge/Licence-OGLv3-blue.svg)](http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3)
8
+
9
+
10
+ Ruby client for Storm Web Services API
11
+
12
+ ## Table of Contents
13
+
14
+ 1. [Installation](#installation)
15
+ 2. [Configuration](#configuration)
16
+ 3. [Usage](#usage)
17
+ 4. [Error Handling](#error-handling)
18
+ 5. [Testing](#testing)
19
+
20
+ ## Installation
21
+
22
+ Add this line to your application's Gemfile:
23
+
24
+ ```ruby
25
+ gem 'defra-ruby-storm'
26
+ ```
27
+ And then execute
28
+ ```sh
29
+ bundle install
30
+ ```
31
+
32
+ Or install it yourself as:
33
+ ```sh
34
+ gem install defra-ruby-storm
35
+ ```
36
+
37
+ ## Configuration
38
+
39
+ You just need to let the gem know the STORM_API_USERNAME AND STORM_API_PASSWORD for the Api access.
40
+
41
+ ```ruby
42
+ # config/initializers/defra_ruby_storm.rb
43
+ require "defra_ruby/storm"
44
+
45
+ DefraRuby::Storm.configure do |config|
46
+ config.storm_api_username = "STORM_API_USERNAME"
47
+ config.storm_api_password = "STORM_API_PASSWORD"
48
+ end
49
+ ```
50
+
51
+ ## Usage
52
+
53
+ The gem provides 3 separate services a host app can use:
54
+
55
+ - DefraRuby::Storm::UserDetailsService
56
+ - DefraRuby::Storm::PauseCallRecordingService
57
+ - DefraRuby::Storm::ResumeCallRecordingService
58
+
59
+
60
+ ### User Details Service
61
+
62
+ ```ruby
63
+ DefraRuby::Storm::UserDetailsService.run(username: 'TestAgentUsername')
64
+
65
+ #<DefraRuby::Storm::GetUserDetailsResponse:0x00007f6b9a3c5160
66
+ @alternative_number=nil,
67
+ @code="0",
68
+ @first_name="First Name",
69
+ @home_tel=nil,
70
+ @last_name="Last Name",
71
+ @mobile=nil,
72
+ @personal_email=nil,
73
+ @user_id="123",
74
+ @user_name="TestAgentUsername",
75
+ @work_email=nil,
76
+ @work_tel=nil>
77
+ ```
78
+ code "0" in api response suggests that the request has been handled successfully
79
+
80
+ ### Pause Call Recording Service
81
+
82
+ ```ruby
83
+ DefraRuby::Storm::PauseCallRecordingService.run(username: 'TestAgentUsername')
84
+
85
+ #<DefraRuby::Storm::RecordingResponse:0x00007f6b99c0f9e8 @result="0">
86
+ ```
87
+ result code "0" in api response suggests that the request has been handled successfully
88
+
89
+ Knowing the agent's user ID, we can pass that into the service, eliminating the need for an additional API call and making request much faster.
90
+
91
+ ```ruby
92
+ DefraRuby::Storm::PauseCallRecordingService.run(agent_user_id: 123)
93
+ ```
94
+
95
+ ### Resume Call Recording Service
96
+
97
+ ```ruby
98
+ DefraRuby::Storm::ResumeCallRecordingService.run(username: 'TestAgentUsername')
99
+
100
+ #<DefraRuby::Storm::RecordingResponse:0x00007f6b99c0f9e8 @result="0">
101
+ ```
102
+ result code "0" in api response suggests that the request has been handled successfully
103
+
104
+ Knowing the agent's user ID, we can pass that into the service, eliminating the need for an additional API call and making request much faster.
105
+
106
+ ```ruby
107
+ DefraRuby::Storm::ResumeCallRecordingService.run(agent_user_id: 123)
108
+ ```
109
+
110
+ ## Error Handling
111
+
112
+ Errors are handled through the DefraRuby::Storm::ApiError class. Here's an example of how you can handle errors:
113
+ ```ruby
114
+ begin
115
+ # some code that might raise an error
116
+ rescue DefraRuby::Storm::ApiError => e
117
+ puts "An error occurred: #{e.message}"
118
+ end
119
+ ```
120
+
121
+ ## Testing
122
+
123
+ ```
124
+ bundle exec rspec
125
+ ```
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "defra_ruby/storm"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ require "irb"
11
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/defra_ruby/storm/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "defra_ruby_storm"
7
+ spec.version = DefraRuby::Storm::VERSION
8
+ spec.authors = ["Defra"]
9
+ spec.email = ["leonid.brujev@defra.gov.uk"]
10
+
11
+ spec.summary = "Ruby client for Storm Web Services API"
12
+ spec.homepage = "https://github.com/DEFRA/defra-ruby-storm"
13
+ spec.required_ruby_version = ">= 3.2"
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = "https://github.com/DEFRA/defra-ruby-storm"
17
+ spec.metadata["changelog_uri"] = "https://github.com/DEFRA/defra-ruby-storm/CHANGELOG.md"
18
+
19
+ # SOAP client
20
+ spec.add_dependency "savon", "~> 2.13.0"
21
+
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ end
27
+ spec.metadata["rubygems_mfa_required"] = "true"
28
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRuby
4
+ module Storm
5
+ class API
6
+ def initialize(config = DefraRuby::Storm::Configuration.call_recording_service_configuration)
7
+ @client = ::Savon.client(config)
8
+ end
9
+
10
+ def get_user_details(username)
11
+ response = @client.call(:get_user_details, message: { "ngw:UserName": username },
12
+ message_tag: :getUserDetailsRequest)
13
+ unless response.http.code == 200 && response.body[:get_user_details_response][:code] == "0"
14
+ handle_error "Failed to get user details for username: #{username}"
15
+ end
16
+
17
+ DefraRuby::Storm::GetUserDetailsResponse.new(response.body[:get_user_details_response])
18
+ end
19
+
20
+ def pause_call_recording(agent_user_id)
21
+ response = @client.call("RedCentrexCalls/Recording",
22
+ message: { "cal:UserID": agent_user_id, "cal:Record": "pause", "cal:Muted": "0" },
23
+ message_tag: :RecordingRequest)
24
+ unless response.http.code == 200 && response.body[:recording_response][:result] == "0"
25
+ handle_error "Failed to pause call recording for agent_user_id: #{agent_user_id}"
26
+ end
27
+
28
+ DefraRuby::Storm::RecordingResponse.new(response.body[:recording_response])
29
+ end
30
+
31
+ def resume_call_recording(agent_user_id)
32
+ response = @client.call("RedCentrexCalls/Recording",
33
+ message: { "cal:UserID": agent_user_id, "cal:Record": "resume" },
34
+ message_tag: :RecordingRequest)
35
+ unless response.http.code == 200 && response.body[:recording_response][:result] == "0"
36
+ handle_error "Failed to resume call recording for agent_user_id: #{agent_user_id}"
37
+ end
38
+
39
+ DefraRuby::Storm::RecordingResponse.new(response.body[:recording_response])
40
+ end
41
+
42
+ def handle_error(error_message)
43
+ raise ApiError, error_message
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRuby
4
+ module Storm
5
+ # Custom error class to handle Storm API errors
6
+ class ApiError < StandardError
7
+ def initialize(msg = "Storm API error")
8
+ super
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRuby
4
+ module Storm
5
+ class Configuration
6
+ attr_accessor :storm_api_username, :storm_api_password,
7
+ :wsdl, :wsse_auth, :soap_version, :pretty_print_xml, :use_wsa_headers, :env_namespace,
8
+ :namespace_identifier, :namespaces, :log
9
+
10
+ def self.user_details_service_configuration
11
+ {
12
+ wsdl: "https://www.timeforstorm.com/serviceportalapi/service.svc?singleWsdl",
13
+ wsse_auth: [DefraRuby::Storm.configuration.storm_api_username,
14
+ DefraRuby::Storm.configuration.storm_api_password],
15
+ soap_version: 2,
16
+ pretty_print_xml: true,
17
+ use_wsa_headers: true,
18
+ env_namespace: :soap,
19
+ namespace_identifier: :ngw,
20
+ namespaces: {
21
+ "xmlns:soap" => "http://www.w3.org/2003/05/soap-envelope",
22
+ "xmlns:ngw" => "http://redwoodtech.com/ws/NGware/NGwareTypes"
23
+ },
24
+ log: false
25
+ }
26
+ end
27
+
28
+ def self.call_recording_service_configuration
29
+ {
30
+ endpoint: "https://www.timeforstorm.com/RedCentrexWebservices/Service.svc", namespace: "http://redcentrex.redwoodtech.com/calls",
31
+ wsse_auth: [DefraRuby::Storm.configuration.storm_api_username,
32
+ DefraRuby::Storm.configuration.storm_api_password],
33
+ soap_version: 2,
34
+ pretty_print_xml: true,
35
+ use_wsa_headers: true,
36
+ env_namespace: :soap,
37
+ namespace_identifier: :cal,
38
+ namespaces: {
39
+ "xmlns:soap" => "http://www.w3.org/2003/05/soap-envelope",
40
+ "xmlns:cal" => "http://redcentrex.redwoodtech.com/calls"
41
+ },
42
+ log: false
43
+ }
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+
5
+ module DefraRuby
6
+ module Storm
7
+ class BaseResponse
8
+ def initialize(args)
9
+ args.each do |key, value|
10
+ next if key == :@xmlns
11
+
12
+ instance_variable_set("@#{key}", value)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRuby
4
+ module Storm
5
+ class GetUserDetailsResponse < BaseResponse
6
+ attr_accessor :code, :user_id, :user_name, :first_name, :last_name, :home_tel, :work_tel, :work_email, :mobile,
7
+ :alternative_number, :personal_emai
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRuby
4
+ module Storm
5
+ class RecordingResponse < BaseResponse
6
+ attr_accessor :result
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRuby
4
+ module Storm
5
+ class BaseService
6
+ def self.run(attrs = {})
7
+ new.run(**attrs)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRuby
4
+ module Storm
5
+ class PauseCallRecordingService < BaseService
6
+ def run(username: nil, agent_user_id: nil)
7
+ if agent_user_id.nil? && !username.nil?
8
+ user_details = DefraRuby::Storm::UserDetailsService.run(username: username)
9
+ agent_user_id = user_details&.user_id
10
+ end
11
+
12
+ raise ArgumentError, "You must provide either a username or a agent_user_id" if agent_user_id.nil?
13
+
14
+ api_client = DefraRuby::Storm::API.new(DefraRuby::Storm::Configuration.call_recording_service_configuration)
15
+ api_client.pause_call_recording(agent_user_id)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRuby
4
+ module Storm
5
+ class ResumeCallRecordingService < BaseService
6
+ def run(username: nil, agent_user_id: nil)
7
+ if agent_user_id.nil? && !username.nil?
8
+ user_details = DefraRuby::Storm::UserDetailsService.run(username: username)
9
+ agent_user_id = user_details&.user_id
10
+ end
11
+ raise ArgumentError, "You must provide either a username or a agent_user_id" if agent_user_id.nil?
12
+
13
+ api_client = DefraRuby::Storm::API.new(DefraRuby::Storm::Configuration.call_recording_service_configuration)
14
+ api_client.resume_call_recording(agent_user_id)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRuby
4
+ module Storm
5
+ class UserDetailsService < BaseService
6
+ def run(username:)
7
+ api_client = DefraRuby::Storm::API.new(DefraRuby::Storm::Configuration.user_details_service_configuration)
8
+ api_client.get_user_details(username)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DefraRuby
4
+ module Storm
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "savon"
4
+
5
+ require_relative "storm/version"
6
+ require_relative "storm/configuration"
7
+ require_relative "storm/api"
8
+ require_relative "storm/api_error"
9
+
10
+ require_relative "storm/services/base_service"
11
+ require_relative "storm/services/user_details_service"
12
+ require_relative "storm/services/pause_call_recording_service"
13
+ require_relative "storm/services/resume_call_recording_service"
14
+
15
+ require_relative "storm/responses/base_response"
16
+ require_relative "storm/responses/get_user_details_response"
17
+ require_relative "storm/responses/recording_response"
18
+
19
+ module DefraRuby
20
+ module Storm
21
+ class << self
22
+ # attr_accessor :configuration
23
+
24
+ def configure
25
+ yield(configuration)
26
+ end
27
+
28
+ def configuration
29
+ @configuration ||= Configuration.new
30
+ @configuration
31
+ end
32
+ end
33
+ end
34
+ end
data/lib/defra_ruby.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "defra_ruby/address"
4
+
5
+ module DefraRuby
6
+ # The Defra Ruby packages namespace
7
+ end
@@ -0,0 +1,6 @@
1
+ module DefraRuby
2
+ module Storm
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
@@ -0,0 +1,29 @@
1
+ # Project key is required. You'll find it in the SonarCloud UI
2
+ sonar.projectKey=DEFRA_defra-ruby-storm
3
+ sonar.organization=defra
4
+
5
+ # This is the name and version displayed in the SonarCloud UI
6
+ sonar.projectName=defra-ruby-storm
7
+
8
+ # This will add the same links in the SonarCloud UI
9
+ sonar.links.homepage=https://github.com/DEFRA/defra-ruby-storm
10
+ sonar.links.ci=https://github.com/DEFRA/defra-ruby-storm/actions
11
+ sonar.links.scm=https://github.com/DEFRA/defra-ruby-storm
12
+ sonar.links.issue=https://github.com/DEFRA/ruby-services-team/issues
13
+
14
+ # Path is relative to the sonar-project.properties file. Replace "\" by "/" on
15
+ # Windows.
16
+ # Because rails generates a number of files, and SonarCloud has no rails and
17
+ # ruby intelligence we have found we have to specify what should be covered.
18
+ # If we don't SonarCloud will do things like take the raw coverage data from
19
+ # simplecov, compare that to all files ion the repo, and score 0 for all the
20
+ # files we don't actually need to test. This severly deflates our scores and
21
+ # means it is not consistent with our previous reporting tool CodeClimate.
22
+ sonar.sources=./lib
23
+ sonar.tests=./spec
24
+
25
+ # Encoding of the source code. Default is default system encoding
26
+ sonar.sourceEncoding=UTF-8
27
+
28
+ sonar.ruby.coverage.reportPaths=coverage/coverage.json
29
+ sonar.ruby.rubocop.reportPaths=rubocop-result.json
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: defra_ruby_storm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Defra
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-11-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: savon
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.13.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.13.0
27
+ description:
28
+ email:
29
+ - leonid.brujev@defra.gov.uk
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".github/dependabot.yml"
35
+ - ".github/workflows/ci.yml"
36
+ - ".gitignore"
37
+ - ".rspec"
38
+ - ".rubocop.yml"
39
+ - ".ruby-version"
40
+ - CHANGELOG.md
41
+ - Gemfile
42
+ - Gemfile.lock
43
+ - LICENSE
44
+ - README.md
45
+ - Rakefile
46
+ - bin/console
47
+ - bin/setup
48
+ - defra_ruby_storm.gemspec
49
+ - lib/defra_ruby.rb
50
+ - lib/defra_ruby/storm.rb
51
+ - lib/defra_ruby/storm/api.rb
52
+ - lib/defra_ruby/storm/api_error.rb
53
+ - lib/defra_ruby/storm/configuration.rb
54
+ - lib/defra_ruby/storm/responses/base_response.rb
55
+ - lib/defra_ruby/storm/responses/get_user_details_response.rb
56
+ - lib/defra_ruby/storm/responses/recording_response.rb
57
+ - lib/defra_ruby/storm/services/base_service.rb
58
+ - lib/defra_ruby/storm/services/pause_call_recording_service.rb
59
+ - lib/defra_ruby/storm/services/resume_call_recording_service.rb
60
+ - lib/defra_ruby/storm/services/user_details_service.rb
61
+ - lib/defra_ruby/storm/version.rb
62
+ - sig/defra_ruby/storm.rbs
63
+ - sonar-project.properties
64
+ homepage: https://github.com/DEFRA/defra-ruby-storm
65
+ licenses: []
66
+ metadata:
67
+ homepage_uri: https://github.com/DEFRA/defra-ruby-storm
68
+ source_code_uri: https://github.com/DEFRA/defra-ruby-storm
69
+ changelog_uri: https://github.com/DEFRA/defra-ruby-storm/CHANGELOG.md
70
+ rubygems_mfa_required: 'true'
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '3.2'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubygems_version: 3.4.10
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: Ruby client for Storm Web Services API
90
+ test_files: []