lingutest_client 0.2.5 → 0.2.7

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: 6eb2319892145efa64cff3f1d7dbeb1a489313deb4cb50ac6bbf36331e56000a
4
- data.tar.gz: 50aa31db07590bd69f582feb3b8dd817c2e9aafd360eeeb81b0e748f2a95d28b
3
+ metadata.gz: 58328c91d7f02542efadd99f57d895d7c58dcf6ed102d6b47fe9c381fa2962e6
4
+ data.tar.gz: 6961066a7c6261455267d24bc18964a8a5da2cbe01148038ef3c72554cf260de
5
5
  SHA512:
6
- metadata.gz: e8998a0b294a52371c3554851705df23b0f044ac85900ecdf2eae2190ce49fd52e893f954f3896cef524975818bddf4645c5b2ab8c35d9381e50f20394031a54
7
- data.tar.gz: 78e5e042bcc734b28a9a4b7e8713ce95a986fd82085c359b81bd46192548d5cc3bb7950e75b542d5890b18c319b8cdd6f6aff66b168dd45620df6feb8ebf4e51
6
+ metadata.gz: f62858cecd6d5c8f5e7213776e369fd5ac58ed40295d20af08ebe617a38dbf483be9f0a1b45d6fa74605827ea66f38737abeb66cf2a8cec65dae840ed774c985
7
+ data.tar.gz: 04e4532fa45107c77f70ff2fa5d6f513433299b4aca5fde9f5bce39178118ec309053531762bafd8acf1803148312acf0eab3a8b09445486920b84e7170393a3
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lingutest_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anatolii Didukh
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-05 00:00:00.000000000 Z
11
+ date: 2025-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable
@@ -120,46 +120,13 @@ email:
120
120
  executables: []
121
121
  extensions: []
122
122
  extra_rdoc_files: []
123
- files:
124
- - ".gitignore"
125
- - ".rspec"
126
- - ".rubocop.yml"
127
- - ".travis.yml"
128
- - CHANGELOG.md
129
- - CODE_OF_CONDUCT.md
130
- - Gemfile
131
- - Gemfile.lock
132
- - README.md
133
- - Rakefile
134
- - bin/console
135
- - bin/setup
136
- - lib/lingutest_client.rb
137
- - lib/lingutest_client/api/operations/create.rb
138
- - lib/lingutest_client/api/operations/delete.rb
139
- - lib/lingutest_client/api/operations/find.rb
140
- - lib/lingutest_client/api/operations/list.rb
141
- - lib/lingutest_client/api/operations/update.rb
142
- - lib/lingutest_client/api/resource.rb
143
- - lib/lingutest_client/base.rb
144
- - lib/lingutest_client/candidate.rb
145
- - lib/lingutest_client/candidate_list.rb
146
- - lib/lingutest_client/client.rb
147
- - lib/lingutest_client/connection.rb
148
- - lib/lingutest_client/exam.rb
149
- - lib/lingutest_client/exam_list.rb
150
- - lib/lingutest_client/examination.rb
151
- - lib/lingutest_client/examination_list.rb
152
- - lib/lingutest_client/types.rb
153
- - lib/lingutest_client/validation_error.rb
154
- - lib/lingutest_client/version.rb
155
- - lingutest_client.gemspec
123
+ files: []
156
124
  homepage: https://github.com/AdeptLMS/lingutest_client
157
125
  licenses: []
158
126
  metadata:
159
127
  rubygems_mfa_required: 'true'
160
128
  homepage_uri: https://github.com/AdeptLMS/lingutest_client
161
129
  source_code_uri: https://github.com/AdeptLMS/lingutest_client
162
- changelog_uri: https://github.com/AdeptLMS/lingutest_client/blob/master/CHANGELOG.md
163
130
  post_install_message:
164
131
  rdoc_options: []
165
132
  require_paths:
@@ -175,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
142
  - !ruby/object:Gem::Version
176
143
  version: '0'
177
144
  requirements: []
178
- rubygems_version: 3.4.18
145
+ rubygems_version: 3.4.19
179
146
  signing_key:
180
147
  specification_version: 4
181
148
  summary: lingutest client
data/.gitignore DELETED
@@ -1,13 +0,0 @@
1
- /.bundle/
2
- /.idea/
3
- /.yardoc
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- vendor
11
-
12
- # rspec failure tracking
13
- .rspec_status
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,9 +0,0 @@
1
- require:
2
- - rubocop-rake
3
- - rubocop-rspec
4
-
5
- AllCops:
6
- NewCops: enable
7
-
8
- Style/Documentation:
9
- Enabled: false
data/.travis.yml DELETED
@@ -1,6 +0,0 @@
1
- ---
2
- language: ruby
3
- cache: bundler
4
- rvm:
5
- - 2.7.0
6
- before_install: gem install bundler -v 2.1.4
data/CHANGELOG.md DELETED
@@ -1,12 +0,0 @@
1
- # CHANGELOG
2
-
3
- ## Next release
4
- ...
5
-
6
- ## 0.2.3 (15 August 2023)
7
- List candidates filters
8
-
9
- ## 0.2.2 (16 March 2023)
10
- Result URL
11
-
12
- ## 0.2.1 (24 February 2023)
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at railsme7@gmail.com. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [https://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: https://contributor-covenant.org
74
- [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile DELETED
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- # Specify your gem's dependencies in lingutest_client.gemspec
6
- gemspec
7
-
8
- gem 'pry'
9
- gem 'rake', '~> 12.0'
10
- gem 'rspec', '~> 3.0'
11
- gem 'rubocop', '~> 1.43.0'
12
- gem 'rubocop-rake'
13
- gem 'rubocop-rspec'
14
- gem 'shoulda-matchers', '~> 5.0'
15
- gem 'vcr', '~> 6.0'
data/Gemfile.lock DELETED
@@ -1,157 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- lingutest_client (0.2.4)
5
- dry-configurable (~> 0.13.0)
6
- dry-schema (~> 1.10.0)
7
- dry-struct (~> 1.5.0)
8
- dry-types (~> 1.6.0)
9
- faraday (~> 1.10.0)
10
- faraday_middleware (~> 1.2.0)
11
- zeitwerk (~> 2.6.7, >= 2.6.7)
12
-
13
- GEM
14
- remote: https://rubygems.org/
15
- specs:
16
- activesupport (7.0.4.2)
17
- concurrent-ruby (~> 1.0, >= 1.0.2)
18
- i18n (>= 1.6, < 2)
19
- minitest (>= 5.1)
20
- tzinfo (~> 2.0)
21
- ast (2.4.2)
22
- coderay (1.1.3)
23
- concurrent-ruby (1.2.0)
24
- diff-lcs (1.5.0)
25
- dry-configurable (0.13.0)
26
- concurrent-ruby (~> 1.0)
27
- dry-core (~> 0.6)
28
- dry-container (0.11.0)
29
- concurrent-ruby (~> 1.0)
30
- dry-core (0.9.1)
31
- concurrent-ruby (~> 1.0)
32
- zeitwerk (~> 2.6)
33
- dry-inflector (0.3.0)
34
- dry-initializer (3.1.1)
35
- dry-logic (1.3.0)
36
- concurrent-ruby (~> 1.0)
37
- dry-core (~> 0.9, >= 0.9)
38
- zeitwerk (~> 2.6)
39
- dry-schema (1.10.6)
40
- concurrent-ruby (~> 1.0)
41
- dry-configurable (~> 0.13, >= 0.13.0)
42
- dry-core (~> 0.5, >= 0.5)
43
- dry-initializer (~> 3.0)
44
- dry-logic (~> 1.2)
45
- dry-types (~> 1.5)
46
- dry-struct (1.5.2)
47
- dry-core (~> 0.9, >= 0.9)
48
- dry-types (~> 1.6)
49
- ice_nine (~> 0.11)
50
- zeitwerk (~> 2.6)
51
- dry-types (1.6.1)
52
- concurrent-ruby (~> 1.0)
53
- dry-container (~> 0.3)
54
- dry-core (~> 0.9, >= 0.9)
55
- dry-inflector (~> 0.1, >= 0.1.2)
56
- dry-logic (~> 1.3, >= 1.3)
57
- zeitwerk (~> 2.6)
58
- faraday (1.10.3)
59
- faraday-em_http (~> 1.0)
60
- faraday-em_synchrony (~> 1.0)
61
- faraday-excon (~> 1.1)
62
- faraday-httpclient (~> 1.0)
63
- faraday-multipart (~> 1.0)
64
- faraday-net_http (~> 1.0)
65
- faraday-net_http_persistent (~> 1.0)
66
- faraday-patron (~> 1.0)
67
- faraday-rack (~> 1.0)
68
- faraday-retry (~> 1.0)
69
- ruby2_keywords (>= 0.0.4)
70
- faraday-em_http (1.0.0)
71
- faraday-em_synchrony (1.0.0)
72
- faraday-excon (1.1.0)
73
- faraday-httpclient (1.0.1)
74
- faraday-multipart (1.0.4)
75
- multipart-post (~> 2)
76
- faraday-net_http (1.0.1)
77
- faraday-net_http_persistent (1.2.0)
78
- faraday-patron (1.0.0)
79
- faraday-rack (1.0.0)
80
- faraday-retry (1.0.3)
81
- faraday_middleware (1.2.0)
82
- faraday (~> 1.0)
83
- i18n (1.12.0)
84
- concurrent-ruby (~> 1.0)
85
- ice_nine (0.11.2)
86
- json (2.6.3)
87
- method_source (1.0.0)
88
- minitest (5.17.0)
89
- multipart-post (2.3.0)
90
- parallel (1.22.1)
91
- parser (3.2.1.0)
92
- ast (~> 2.4.1)
93
- pry (0.14.2)
94
- coderay (~> 1.1)
95
- method_source (~> 1.0)
96
- rainbow (3.1.1)
97
- rake (12.3.3)
98
- regexp_parser (2.7.0)
99
- rexml (3.2.5)
100
- rspec (3.12.0)
101
- rspec-core (~> 3.12.0)
102
- rspec-expectations (~> 3.12.0)
103
- rspec-mocks (~> 3.12.0)
104
- rspec-core (3.12.1)
105
- rspec-support (~> 3.12.0)
106
- rspec-expectations (3.12.2)
107
- diff-lcs (>= 1.2.0, < 2.0)
108
- rspec-support (~> 3.12.0)
109
- rspec-mocks (3.12.3)
110
- diff-lcs (>= 1.2.0, < 2.0)
111
- rspec-support (~> 3.12.0)
112
- rspec-support (3.12.0)
113
- rubocop (1.43.0)
114
- json (~> 2.3)
115
- parallel (~> 1.10)
116
- parser (>= 3.2.0.0)
117
- rainbow (>= 2.2.2, < 4.0)
118
- regexp_parser (>= 1.8, < 3.0)
119
- rexml (>= 3.2.5, < 4.0)
120
- rubocop-ast (>= 1.24.1, < 2.0)
121
- ruby-progressbar (~> 1.7)
122
- unicode-display_width (>= 2.4.0, < 3.0)
123
- rubocop-ast (1.26.0)
124
- parser (>= 3.2.1.0)
125
- rubocop-capybara (2.17.1)
126
- rubocop (~> 1.41)
127
- rubocop-rake (0.6.0)
128
- rubocop (~> 1.0)
129
- rubocop-rspec (2.18.1)
130
- rubocop (~> 1.33)
131
- rubocop-capybara (~> 2.17)
132
- ruby-progressbar (1.11.0)
133
- ruby2_keywords (0.0.5)
134
- shoulda-matchers (5.3.0)
135
- activesupport (>= 5.2.0)
136
- tzinfo (2.0.6)
137
- concurrent-ruby (~> 1.0)
138
- unicode-display_width (2.4.2)
139
- vcr (6.1.0)
140
- zeitwerk (2.6.7)
141
-
142
- PLATFORMS
143
- ruby
144
-
145
- DEPENDENCIES
146
- lingutest_client!
147
- pry
148
- rake (~> 12.0)
149
- rspec (~> 3.0)
150
- rubocop (~> 1.43.0)
151
- rubocop-rake
152
- rubocop-rspec
153
- shoulda-matchers (~> 5.0)
154
- vcr (~> 6.0)
155
-
156
- BUNDLED WITH
157
- 2.4.18
data/README.md DELETED
@@ -1,57 +0,0 @@
1
- # LingutestClient
2
-
3
- This library will allow you to communicate with Lingu Test API. You can create examinations for client, and receive examination results. You need API token from Lingu Test to use this gem. Check [documentation](https://test.lingu.com/documentation) for API calls.
4
-
5
-
6
- ## Installation
7
-
8
- Add this line to your application's Gemfile:
9
-
10
- ```ruby
11
- gem 'lingutest_client'
12
- ```
13
-
14
- And then execute:
15
-
16
- $ bundle install
17
-
18
- ## Configuration
19
-
20
- ```ruby
21
- # config/initializers/lingutest_client.rb
22
-
23
- LingutestClient.configure do |config|
24
- config.api_base = 'https://test.lingu.com/api/v1/'
25
- config.api_key = 'yourLinguTestApiKey'
26
- end
27
- ```
28
-
29
- ## Usage
30
-
31
- ```ruby
32
- LingutestClient::Exam.list
33
-
34
- LingutestClient::Candidate.list
35
- LingutestClient::Candidate.find(id)
36
- LingutestClient::Candidate.create(fname:, lname:, email:, ssn:, gender:, mobile:)
37
- LingutestClient::Candidate.update(fname:, lname:, email:, ssn:, gender:, mobile:)
38
-
39
- LingutestClient::Examination.list
40
- LingutestClient::Examination.find(id)
41
- LingutestClient::Examination.create(candidate_id:, exam_id:, expires_at:)
42
- ```
43
-
44
- ## Development
45
-
46
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
47
-
48
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
49
-
50
- ## Contributing
51
-
52
- Bug reports and pull requests are welcome on GitHub at https://github.com/AdeptLMS/lingutest_client. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/AdeptLMS/lingutest_client/blob/master/CODE_OF_CONDUCT.md).
53
-
54
-
55
- ## Code of Conduct
56
-
57
- Everyone interacting in the LingutestClient project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/AdeptLMS/lingutest_client/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile DELETED
@@ -1,8 +0,0 @@
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
- task default: :spec
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/setup'
5
- require 'lingutest_client'
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
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require 'irb'
15
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
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
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- module Api
5
- module Operations
6
- module Create
7
- module ClassMethods
8
- def create(**params)
9
- schema = const_get(:CreateSchema).call(params)
10
- unless schema.success?
11
- raise ValidationError,
12
- schema.errors.to_h.to_a.first.flatten.join(' ')
13
- end
14
-
15
- response = Client.post(
16
- resource_url, self::OBJECT_NAME => schema.to_h
17
- )
18
- new(response.body[self::OBJECT_NAME])
19
- end
20
- end
21
-
22
- def self.included(base)
23
- base.extend ClassMethods
24
- end
25
- end
26
- end
27
- end
28
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- module Api
5
- module Operations
6
- module Delete
7
- module ClassMethods
8
- def delete(id)
9
- Client.delete(member_resource_url(id)).body && nil
10
- end
11
-
12
- private
13
-
14
- def member_resource_url(id)
15
- "#{resource_url}/#{id}"
16
- end
17
- end
18
-
19
- module InstanceMethods
20
- def delete
21
- self.class.delete(id)
22
- end
23
- end
24
-
25
- def self.included(base)
26
- base.extend ClassMethods
27
- base.send(:include, InstanceMethods)
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- module Api
5
- module Operations
6
- module Find
7
- module ClassMethods
8
- def find(id)
9
- new(Client.get("#{resource_url}/#{id}").body[self::OBJECT_NAME])
10
- end
11
- end
12
-
13
- module InstanceMethods
14
- def reload
15
- self.class.find(id)
16
- end
17
- end
18
-
19
- def self.included(base)
20
- base.extend ClassMethods
21
- base.send(:include, InstanceMethods)
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- module Api
5
- module Operations
6
- module List
7
- DELEGATED_METHODS = %i[
8
- each
9
- empty?
10
- find
11
- first
12
- last
13
- map
14
- reject
15
- select
16
- size
17
- ].freeze
18
-
19
- class << self
20
- def module(list_type, params_schema = nil) # rubocop:disable Metrics/MethodLength
21
- Module.new do
22
- class_methods_module = Module.new
23
-
24
- class_methods_module.define_method :list do |**options|
25
- params = options.dup
26
- if params_schema
27
- result = params_schema.call(options)
28
- raise ArgumentError, result.errors if result.failure?
29
-
30
- params = result.to_h
31
- end
32
- list_type.new(Client.get(resource_url, **params).body)
33
- end
34
-
35
- define_singleton_method :included do |base|
36
- base.extend class_methods_module
37
- end
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
44
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- module Api
5
- module Operations
6
- module Update
7
- module ClassMethods
8
- def update(id, **params)
9
- schema = const_get(:UpdateSchema).call(params)
10
- unless schema.success?
11
- raise ValidationError,
12
- schema.errors.to_h.to_a.first.flatten.join(' ')
13
- end
14
-
15
- new(
16
- Client.put(
17
- member_resource_url(id), self::OBJECT_NAME => schema.to_h
18
- ).body[self::OBJECT_NAME]
19
- )
20
- end
21
-
22
- private
23
-
24
- def member_resource_url(id)
25
- "#{resource_url}/#{id}"
26
- end
27
- end
28
-
29
- module InstanceMethods
30
- def update(**params)
31
- self.class.update(id, params)
32
- end
33
- end
34
-
35
- def self.included(base)
36
- base.extend ClassMethods
37
- base.send(:include, InstanceMethods)
38
- end
39
- end
40
- end
41
- end
42
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'ostruct'
4
-
5
- module LingutestClient
6
- module Api
7
- module Resource
8
- module ClassMethods
9
- def resource_url
10
- "/api/v1/#{self::OBJECT_NAME.to_s.downcase.tr('.', '/')}s"
11
- end
12
- end
13
-
14
- def self.included(base)
15
- base.extend ClassMethods
16
- end
17
- end
18
- end
19
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- class Base < Dry::Struct
5
- extend Forwardable
6
-
7
- def_delegator :to_hash, :to_json
8
-
9
- def to_hash(object = self, type = self.class) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
10
- type.schema.each_with_object({}) do |key, res|
11
- name = key.name
12
- attr = key.type
13
- if array?(attr)
14
- values = ::Array.wrap(object.public_send(name))
15
- res[name] = values.map do |value_item|
16
- serialize(value_item, attr.member)
17
- end
18
- elsif bool?(attr)
19
- value = object.public_send("#{name}?")
20
- res[name] = value
21
- else
22
- value = object.public_send(name)
23
- res[name] = serialize(value, attr)
24
- end
25
- end
26
- end
27
-
28
- private
29
-
30
- def serialize(object, type)
31
- complex?(type) ? to_hash(object, type) : object
32
- end
33
-
34
- def complex?(attribute)
35
- attribute.respond_to?(:<) && attribute < Base
36
- end
37
-
38
- def bool?(attribute)
39
- attribute.primitive?(true)
40
- end
41
-
42
- def array?(attribute)
43
- attribute.primitive?([])
44
- end
45
- end
46
- end
@@ -1,50 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- class Candidate < Base
5
- CreateSchema = Dry::Schema.Params do
6
- required(:fname).filled(:string)
7
- required(:lname).filled(:string)
8
- required(:email).filled(Types::Email)
9
- optional(:locale).filled(:string)
10
- optional(:mobile).filled(:string)
11
- optional(:gender).filled(Types::Gender)
12
- optional(:ssn).filled(Types::Ssn)
13
- end
14
- UpdateSchema = Dry::Schema.Params do
15
- optional(:fname).filled(:string)
16
- optional(:lname).filled(:string)
17
- optional(:email).filled(Types::Email)
18
- optional(:locale).filled(:string)
19
- optional(:mobile).filled(:string)
20
- optional(:gender).filled(Types::Gender)
21
- optional(:ssn).filled(Types::Ssn)
22
- end
23
-
24
- FilterSchema = Dry::Schema.Params do
25
- optional(:page)
26
- optional(:per_page)
27
- optional(:email_eq).filled(Types::Email)
28
- optional(:fname_eq).filled(:string)
29
- optional(:lname_eq).filled(:string)
30
- end
31
-
32
- OBJECT_NAME = :candidate
33
-
34
- include Api::Resource
35
- include Api::Operations::List.module(CandidateList, FilterSchema)
36
- include Api::Operations::Create
37
- include Api::Operations::Find
38
- include Api::Operations::Delete
39
- include Api::Operations::Update
40
-
41
- attribute :id, Types::Coercible::Integer.default(0)
42
- attribute :email, Types::Coercible::String.default('')
43
- attribute :fname, Types::Coercible::String.default('')
44
- attribute :lname, Types::Coercible::String.default('')
45
- attribute :mobile, Types::Coercible::String.default('')
46
- attribute :locale, Types::Coercible::String.default('')
47
- attribute :ssn, Types::Coercible::String.default('')
48
- attribute :gender, Types::Gender
49
- end
50
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- class CandidateList < Base
5
- include Enumerable
6
- delegate ::LingutestClient::Api::Operations::List::DELEGATED_METHODS => :candidates
7
-
8
- attribute :candidates, Types::Array.of(Candidate)
9
- end
10
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- class Client
5
- include Connection
6
- end
7
- end
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'faraday'
4
-
5
- module LingutestClient
6
- module Connection
7
- module ClassMethods
8
- def client
9
- Thread.current[:lingutest_client] ||= connection
10
- end
11
-
12
- def connection # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
13
- Thread.current[:lingutest_default_connection] ||=
14
- Faraday.new(url: LingutestClient.config.api_base) do |c|
15
- c.request :json
16
- c.response :raise_error
17
- c.response :json,
18
- content_type: /\bjson$/,
19
- parser_options: { symbolize_names: true }
20
- c.headers['X-Api-Token'] =
21
- format('Token token="%<key>s"',
22
- key: LingutestClient.config.api_key)
23
- c.headers[:user_agent] = 'Lingutest Ruby Client'
24
- c.headers['Content-Type'] = 'application/json'
25
- c.headers['Accept'] = 'application/json'
26
- c.adapter Faraday.default_adapter
27
- end
28
- end
29
- end
30
-
31
- def self.included(base)
32
- base.extend ClassMethods
33
- base.extend Forwardable
34
- base.class_eval do
35
- def_delegators :connection, :get, :post, :delete, :put, :patch
36
- end
37
- base.singleton_class.extend Forwardable
38
- base.singleton_class.class_eval do
39
- def_delegators :client, :get, :post, :delete, :put, :patch
40
- end
41
- end
42
- end
43
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- class Exam < Base
5
- OBJECT_NAME = :exam
6
-
7
- include Api::Resource
8
- include Api::Operations::List.module(ExamList)
9
-
10
- FilterSchema = Dry::Schema.Params do
11
- config.validate_keys = true
12
- optional(:page).filled(Types::Coercible::Integer)
13
- optional(:per_page).filled(Types::Coercible::Integer)
14
-
15
- optional(:locale_eq).filled(Types::Coercible::String)
16
- optional(:price_gt).filled(Types::Coercible::Integer)
17
- end
18
-
19
- attribute :id, Types::Coercible::Integer.optional.default(0)
20
- attribute :name, Types::Coercible::String.optional.default('')
21
- attribute :locale, Types::Coercible::String.optional.default('')
22
- attribute :description, Types::Coercible::String.optional.default('')
23
- attribute :price, Types::Coercible::Decimal.optional.default(0)
24
- attribute :updated_at, Types::DateTime.optional.default(nil)
25
- attribute :created_at, Types::DateTime.optional.default(nil)
26
- end
27
- end
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- class ExamList < Base
5
- include Enumerable
6
- delegate ::LingutestClient::Api::Operations::List::DELEGATED_METHODS => :exams
7
-
8
- attribute :exams, Types::Array.of(Exam)
9
- end
10
- end
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- class Examination < Base
5
- OBJECT_NAME = :examination
6
-
7
- STATUSES = %w[
8
- pending
9
- in_progress
10
- completed
11
- pending_review
12
- reviewed
13
- ].freeze
14
-
15
- CreateSchema = Dry::Schema.Params do
16
- required(:exam_id).filled(Types::Coercible::Integer)
17
- required(:candidate_id).filled(Types::Coercible::Integer)
18
- required(:expires_at).filled(Types::DateTime)
19
- optional(:redirect_url).filled(Types::Url)
20
-
21
- optional(:team_id).filled(Types::Coercible::String)
22
- optional(:team_group_id).filled(Types::Coercible::String)
23
- optional(:student_id).filled(Types::Coercible::String)
24
- end
25
-
26
- FilterSchema = Dry::Schema.Params do
27
- config.validate_keys = true
28
- optional(:page).filled(Types::Coercible::Integer)
29
- optional(:per_page).filled(Types::Coercible::Integer)
30
-
31
- optional(:team_id_eq).filled(Types::Coercible::String)
32
- optional(:team_group_id_eq).filled(Types::Coercible::String)
33
- optional(:student_id_eq).filled(Types::Coercible::String)
34
-
35
- optional(:price_gteq).filled(Types::Coercible::Integer)
36
- optional(:created_at_gteq).filled(Types::DateTime)
37
- optional(:created_at_lteq).filled(Types::DateTime)
38
- end
39
-
40
- include Api::Resource
41
- include Api::Operations::List.module(ExaminationList, FilterSchema)
42
- include Api::Operations::Create
43
- include Api::Operations::Find
44
-
45
- attribute :id, Types::Integer.optional
46
- attribute :exam, Exam.optional.default(nil)
47
- attribute :candidate, Candidate.optional.default(nil)
48
- attribute :total_score, Types::Integer.optional.default(0)
49
- attribute :max_score, Types::Integer.optional.default(0)
50
- attribute :tasks_limit, Types::Integer.optional.default(0)
51
- attribute :total_time_spent, Types::Integer.optional.default(0)
52
- attribute :code, Types::String.optional.default('')
53
- attribute :redirect_url, Types::String.optional
54
- attribute :price, Types::Coercible::Decimal.optional.default(0)
55
-
56
- attribute :team_id, Types::String.optional.default(nil)
57
- attribute :team_group_id, Types::String.optional.default(nil)
58
- attribute :student_id, Types::String.optional.default(nil)
59
-
60
- attribute :status, Types::String.optional.enum(*STATUSES)
61
-
62
- attribute :expires_at, Types::Time.optional.default(nil)
63
- attribute :created_at, Types::Time.optional.default(nil)
64
- attribute :updated_at, Types::Time.optional.default(nil)
65
-
66
- def url
67
- URI.join(LingutestClient.config.api_base.to_s, "/#{code}").to_s
68
- end
69
-
70
- def result_url
71
- URI.join(LingutestClient.config.api_base.to_s, "/examinations/#{code}").to_s
72
- end
73
-
74
- STATUSES.each do |status|
75
- define_method "#{status}?" do
76
- self.status == status
77
- end
78
- end
79
- end
80
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- class ExaminationList < Base
5
- include Enumerable
6
- delegate ::LingutestClient::Api::Operations::List::DELEGATED_METHODS => :examinations
7
-
8
- attribute :examinations, Types::Array.of(Examination)
9
-
10
- attribute :limit_value, Types::Coercible::Integer
11
- attribute :current_page, Types::Coercible::Integer
12
- attribute :total_pages, Types::Coercible::Integer
13
- attribute :total_count, Types::Coercible::Integer
14
- attribute :per_page, Types::Coercible::Integer
15
- attribute :page, Types::Coercible::Integer
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'dry-types'
4
- require 'uri/mailto'
5
-
6
- module LingutestClient
7
- module Types
8
- include Dry.Types()
9
-
10
- DateTime = Strict::Date | JSON::Date | Strict::Time
11
- Time = Strict::Time | Types::JSON::Time
12
- Gender = Types::String.enum('unknown', 'male', 'female')
13
- Email = Types::String.constrained(format: URI::MailTo::EMAIL_REGEXP)
14
- Ssn = Types::String.constrained(format: /\A(\d{10,11}|\d{5,6}|^$)\z/i)
15
- Url = Types::String.constrained(format: %r{\Ahttps?://.+\z}i)
16
- end
17
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- class ValidationError < StandardError
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LingutestClient
4
- VERSION = '0.2.5'
5
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.unshift File.dirname(__FILE__)
4
- require 'dry-configurable'
5
- require 'dry-schema'
6
- require 'dry-struct'
7
- require 'dry-types'
8
- require 'forwardable'
9
- require 'zeitwerk'
10
-
11
- Zeitwerk::Loader.for_gem.setup
12
-
13
- module LingutestClient
14
- extend Dry::Configurable
15
-
16
- setting :api_base,
17
- default: 'https://test.lingu.com/api/v1/',
18
- constructor: proc { |value| URI.parse(value) },
19
- reader: true
20
-
21
- setting :api_key,
22
- constructor: proc { |value| value.to_s },
23
- reader: true
24
- end
@@ -1,39 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative './lib/lingutest_client/version'
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = 'lingutest_client'
7
- spec.version = LingutestClient::VERSION
8
- spec.authors = ['Anatolii Didukh']
9
- spec.email = ['railsme7@gmail.com']
10
-
11
- spec.summary = 'lingutest client'
12
- spec.description = 'test.lingu.com API ruby client'
13
- spec.homepage = 'https://github.com/AdeptLMS/lingutest_client'
14
- spec.required_ruby_version = Gem::Requirement.new('>= 2.7.6')
15
-
16
- spec.metadata['rubygems_mfa_required'] = 'true'
17
- # spec.metadata['allowed_push_host'] = "Set to 'http://mygemserver.com'"
18
-
19
- spec.metadata['homepage_uri'] = spec.homepage
20
- spec.metadata['source_code_uri'] = 'https://github.com/AdeptLMS/lingutest_client'
21
- spec.metadata['changelog_uri'] = 'https://github.com/AdeptLMS/lingutest_client/blob/master/CHANGELOG.md'
22
-
23
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
- `git ls-files -z`
25
- .split("\x0")
26
- .reject { |f| f.match(%r{^(test|spec|features)/}) }
27
- end
28
- spec.bindir = 'exe'
29
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
- spec.require_paths = ['lib']
31
-
32
- spec.add_dependency 'dry-configurable', '~> 0.13.0'
33
- spec.add_dependency 'dry-schema', '~> 1.10.0'
34
- spec.add_dependency 'dry-struct', '~> 1.5.0'
35
- spec.add_dependency 'dry-types', '~> 1.6.0'
36
- spec.add_dependency 'faraday', '~> 1.10.0'
37
- spec.add_dependency 'faraday_middleware', '~> 1.2.0'
38
- spec.add_dependency 'zeitwerk', '~> 2.6.7', '>= 2.6.7'
39
- end