test-words-api-client-sdk 1.0.0

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.
Files changed (32) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +76 -0
  4. data/lib/words_api/api_helper.rb +10 -0
  5. data/lib/words_api/client.rb +60 -0
  6. data/lib/words_api/configuration.rb +127 -0
  7. data/lib/words_api/controllers/ap_is_controller.rb +134 -0
  8. data/lib/words_api/controllers/base_controller.rb +66 -0
  9. data/lib/words_api/exceptions/api_exception.rb +10 -0
  10. data/lib/words_api/http/auth/custom_header_authentication.rb +44 -0
  11. data/lib/words_api/http/http_call_back.rb +10 -0
  12. data/lib/words_api/http/http_method_enum.rb +10 -0
  13. data/lib/words_api/http/http_request.rb +10 -0
  14. data/lib/words_api/http/http_response.rb +10 -0
  15. data/lib/words_api/models/base_model.rb +62 -0
  16. data/lib/words_api/models/definitions_response.rb +56 -0
  17. data/lib/words_api/models/examples_response.rb +56 -0
  18. data/lib/words_api/models/frequency_details.rb +64 -0
  19. data/lib/words_api/models/frequency_response.rb +56 -0
  20. data/lib/words_api/models/pronunciation_details.rb +67 -0
  21. data/lib/words_api/models/pronunciation_response.rb +57 -0
  22. data/lib/words_api/models/syllable_details.rb +59 -0
  23. data/lib/words_api/models/synonyms_response.rb +56 -0
  24. data/lib/words_api/models/word_details.rb +152 -0
  25. data/lib/words_api/models/word_response.rb +94 -0
  26. data/lib/words_api/utilities/date_time_helper.rb +11 -0
  27. data/lib/words_api/utilities/file_wrapper.rb +16 -0
  28. data/lib/words_api.rb +49 -0
  29. data/test/controllers/controller_test_base.rb +29 -0
  30. data/test/controllers/test_ap_is_controller.rb +171 -0
  31. data/test/http_response_catcher.rb +19 -0
  32. metadata +146 -0
@@ -0,0 +1,94 @@
1
+ # words_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module WordsApi
7
+ # This custom type contains the response for word API.
8
+ class WordResponse < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # The word that is searched.
13
+ # @return [String]
14
+ attr_accessor :word
15
+
16
+ # This field contains detailed information of the word.
17
+ # @return [Array[WordDetails]]
18
+ attr_accessor :results
19
+
20
+ # This model contains pronunciation details of a specific word.
21
+ # @return [Object]
22
+ attr_accessor :pronunciation
23
+
24
+ # The frequency of the word usage.
25
+ # @return [Float]
26
+ attr_accessor :frequency
27
+
28
+ # This custom type contains the syllable details for word API.
29
+ # @return [SyllableDetails]
30
+ attr_accessor :syllables
31
+
32
+ # A mapping from model property names to API property names.
33
+ def self.names
34
+ @_hash = {} if @_hash.nil?
35
+ @_hash['word'] = 'word'
36
+ @_hash['results'] = 'results'
37
+ @_hash['pronunciation'] = 'pronunciation'
38
+ @_hash['frequency'] = 'frequency'
39
+ @_hash['syllables'] = 'syllables'
40
+ @_hash
41
+ end
42
+
43
+ # An array for optional fields
44
+ def self.optionals
45
+ %w[
46
+ pronunciation
47
+ frequency
48
+ syllables
49
+ ]
50
+ end
51
+
52
+ # An array for nullable fields
53
+ def self.nullables
54
+ []
55
+ end
56
+
57
+ def initialize(word = nil, results = nil, pronunciation = SKIP,
58
+ frequency = SKIP, syllables = SKIP)
59
+ @word = word
60
+ @results = results
61
+ @pronunciation = pronunciation unless pronunciation == SKIP
62
+ @frequency = frequency unless frequency == SKIP
63
+ @syllables = syllables unless syllables == SKIP
64
+ end
65
+
66
+ # Creates an instance of the object from a hash.
67
+ def self.from_hash(hash)
68
+ return nil unless hash
69
+
70
+ # Extract variables from the hash.
71
+ word = hash.key?('word') ? hash['word'] : nil
72
+ # Parameter is an array, so we need to iterate through it
73
+ results = nil
74
+ unless hash['results'].nil?
75
+ results = []
76
+ hash['results'].each do |structure|
77
+ results << (WordDetails.from_hash(structure) if structure)
78
+ end
79
+ end
80
+
81
+ results = nil unless hash.key?('results')
82
+ pronunciation = hash.key?('pronunciation') ? hash['pronunciation'] : SKIP
83
+ frequency = hash.key?('frequency') ? hash['frequency'] : SKIP
84
+ syllables = SyllableDetails.from_hash(hash['syllables']) if hash['syllables']
85
+
86
+ # Create object from extracted values.
87
+ WordResponse.new(word,
88
+ results,
89
+ pronunciation,
90
+ frequency,
91
+ syllables)
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,11 @@
1
+ # words_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'date'
7
+ module WordsApi
8
+ # A utility that supports dateTime conversion to different formats
9
+ class DateTimeHelper < CoreLibrary::DateTimeHelper
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ # words_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module WordsApi
7
+ # A utility to allow users to set the content-type for files
8
+ class FileWrapper < CoreLibrary::FileWrapper
9
+ # The constructor.
10
+ # @param [File] file The file to be sent in the request.
11
+ # @param [string] content_type The content type of the provided file.
12
+ def initialize(file, content_type: 'application/octet-stream')
13
+ super
14
+ end
15
+ end
16
+ end
data/lib/words_api.rb ADDED
@@ -0,0 +1,49 @@
1
+ # words_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'date'
7
+ require 'json'
8
+
9
+ require 'apimatic_core_interfaces'
10
+ require 'apimatic_core'
11
+ require 'apimatic_faraday_client_adapter'
12
+
13
+ require_relative 'words_api/api_helper'
14
+ require_relative 'words_api/client'
15
+
16
+ # Utilities
17
+ require_relative 'words_api/utilities/file_wrapper'
18
+ require_relative 'words_api/utilities/date_time_helper'
19
+
20
+ # Http
21
+ require_relative 'words_api/http/http_call_back'
22
+ require_relative 'words_api/http/http_method_enum'
23
+ require_relative 'words_api/http/http_request'
24
+ require_relative 'words_api/http/http_response'
25
+
26
+ # Logger
27
+ require_relative 'words_api/http/auth/custom_header_authentication'
28
+
29
+ # Models
30
+ require_relative 'words_api/models/base_model'
31
+ require_relative 'words_api/models/definitions_response'
32
+ require_relative 'words_api/models/examples_response'
33
+ require_relative 'words_api/models/pronunciation_details'
34
+ require_relative 'words_api/models/synonyms_response'
35
+ require_relative 'words_api/models/frequency_response'
36
+ require_relative 'words_api/models/word_details'
37
+ require_relative 'words_api/models/word_response'
38
+ require_relative 'words_api/models/pronunciation_response'
39
+ require_relative 'words_api/models/frequency_details'
40
+ require_relative 'words_api/models/syllable_details'
41
+
42
+ # Exceptions
43
+ require_relative 'words_api/exceptions/api_exception'
44
+
45
+ require_relative 'words_api/configuration'
46
+
47
+ # Controllers
48
+ require_relative 'words_api/controllers/base_controller'
49
+ require_relative 'words_api/controllers/ap_is_controller'
@@ -0,0 +1,29 @@
1
+ # words_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'json'
7
+ require 'minitest/autorun'
8
+ require 'minitest/hell'
9
+ require 'minitest/pride'
10
+ require 'minitest/proveit'
11
+ require 'words_api'
12
+ require_relative '../http_response_catcher'
13
+
14
+ class ControllerTestBase < Minitest::Test
15
+ parallelize_me!
16
+ include WordsApi
17
+ include CoreLibrary
18
+
19
+ # Create configuration and set any test parameters
20
+ def create_configuration
21
+ Configuration.new(http_callback: HttpResponseCatcher.new)
22
+ end
23
+
24
+ # Initializes the base test controller
25
+ def setup_class
26
+ _config = create_configuration
27
+ @client = Client.new(config: _config)
28
+ end
29
+ end
@@ -0,0 +1,171 @@
1
+ # words_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require_relative 'controller_test_base'
7
+
8
+ class APIsControllerTests < ControllerTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ setup_class
12
+ @controller = @client.ap_is
13
+ @response_catcher = @controller.http_call_back
14
+ end
15
+
16
+ # Get synonyms of a word.
17
+ def test_synonyms
18
+ # Parameters for the API call
19
+ word = 'lovely'
20
+
21
+ # Perform the API call through the SDK function
22
+ result = @controller.synonyms(word)
23
+
24
+ # Test response code
25
+ assert_equal(200, @response_catcher.response.status_code)
26
+
27
+ # Test headers
28
+ expected_headers = {}
29
+ expected_headers['content-type'] = 'application/json'
30
+
31
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
32
+
33
+ # Test whether the captured response is as we expected
34
+ refute_nil(result)
35
+ expected_body = JSON.parse(
36
+ '{"word":"lovely","synonyms":["adorable","endearing","cover girl","pin-u'\
37
+ 'p"]}'
38
+ )
39
+ received_body = JSON.parse(@response_catcher.response.raw_body)
40
+ assert(ComparisonHelper.match_body(expected_body, received_body))
41
+ end
42
+
43
+ # Get definitions of a word, including the part of speech.
44
+ def test_definitions
45
+ # Parameters for the API call
46
+ word = 'lovely'
47
+
48
+ # Perform the API call through the SDK function
49
+ result = @controller.definitions(word)
50
+
51
+ # Test response code
52
+ assert_equal(200, @response_catcher.response.status_code)
53
+
54
+ # Test headers
55
+ expected_headers = {}
56
+ expected_headers['content-type'] = 'application/json'
57
+
58
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
59
+
60
+ # Test whether the captured response is as we expected
61
+ refute_nil(result)
62
+ expected_body = JSON.parse(
63
+ '{"word":"lovely","definition":["lovable especially in a childlike or na'\
64
+ 'ive way","a very pretty girl who works as a photographer\'s model","app'\
65
+ 'ealing to the emotions as well as the eye"]}'
66
+ )
67
+ received_body = JSON.parse(@response_catcher.response.raw_body)
68
+ assert(ComparisonHelper.match_body(expected_body, received_body))
69
+ end
70
+
71
+ # How to pronounce a word, according to the International Phonetic Alphabet. May include multiple results if the word is pronounced differently depending on its part of speech.
72
+ def test_pronunciation
73
+ # Parameters for the API call
74
+ word = 'wind'
75
+
76
+ # Perform the API call through the SDK function
77
+ result = @controller.pronunciation(word)
78
+
79
+ # Test response code
80
+ assert_equal(200, @response_catcher.response.status_code)
81
+
82
+ # Test headers
83
+ expected_headers = {}
84
+ expected_headers['content-type'] = 'application/json'
85
+
86
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
87
+
88
+ # Test whether the captured response is as we expected
89
+ refute_nil(result)
90
+ expected_body = JSON.parse(
91
+ '{"word":"wind","pronunciation":{"all":"wɪnd","noun":"wɪnd","verb":"waɪn'\
92
+ 'd"}}'
93
+ )
94
+ received_body = JSON.parse(@response_catcher.response.raw_body)
95
+ assert(ComparisonHelper.match_body(expected_body, received_body))
96
+ end
97
+
98
+ # Retrieve information about a word. Results can include definitions, part of speech, synonyms, related words, syllables, and pronunciation. This method is useful to see which relationships are attached to which definition and part of speech of a word.
99
+ def test_word
100
+ # Parameters for the API call
101
+ word = 'Testing'
102
+
103
+ # Perform the API call through the SDK function
104
+ result = @controller.word(word)
105
+
106
+ # Test response code
107
+ assert_equal(200, @response_catcher.response.status_code)
108
+
109
+ # Test headers
110
+ expected_headers = {}
111
+ expected_headers['content-type'] = 'application/json'
112
+
113
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
114
+ end
115
+
116
+ # Get examples of how the word is used.
117
+ def test_examples
118
+ # Parameters for the API call
119
+ word = 'wind'
120
+
121
+ # Perform the API call through the SDK function
122
+ result = @controller.examples(word)
123
+
124
+ # Test response code
125
+ assert_equal(200, @response_catcher.response.status_code)
126
+
127
+ # Test headers
128
+ expected_headers = {}
129
+ expected_headers['content-type'] = 'application/json'
130
+
131
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
132
+
133
+ # Test whether the captured response is as we expected
134
+ refute_nil(result)
135
+ expected_body = JSON.parse(
136
+ '{"word":"testing","examples":["there are laboratories for commercial te'\
137
+ 'sting","it involved testing thousands of children for smallpox","they a'\
138
+ 'greed to end the testing of atomic weapons"]}'
139
+ )
140
+ received_body = JSON.parse(@response_catcher.response.raw_body)
141
+ assert(ComparisonHelper.match_body(expected_body, received_body))
142
+ end
143
+
144
+ # Expands upon the frequency score returned by the main /words/{word} endpoint. Returns zipf, a score indicating how common the word is in the English language, with a range of 1 to 7; per Million, the number of times the word is likely to appear in a corpus of one million English words; and diversity, a 0-1 scale the shows the likelihood of the word appearing in an English document that is part of a corpus.
145
+ def test_frequency
146
+ # Parameters for the API call
147
+ word = 'lovely'
148
+
149
+ # Perform the API call through the SDK function
150
+ result = @controller.frequency(word)
151
+
152
+ # Test response code
153
+ assert_equal(200, @response_catcher.response.status_code)
154
+
155
+ # Test headers
156
+ expected_headers = {}
157
+ expected_headers['content-type'] = 'application/json'
158
+
159
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
160
+
161
+ # Test whether the captured response is as we expected
162
+ refute_nil(result)
163
+ expected_body = JSON.parse(
164
+ '{"word":"wind","frequency":{"zipf":4.81,"perMillion":64.22,"diversity":'\
165
+ '0.2}}'
166
+ )
167
+ received_body = JSON.parse(@response_catcher.response.raw_body)
168
+ assert(ComparisonHelper.match_body(expected_body, received_body))
169
+ end
170
+
171
+ end
@@ -0,0 +1,19 @@
1
+ # words_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ class HttpResponseCatcher < WordsApi::HttpCallBack
7
+ attr_accessor :response
8
+
9
+ def on_before_request(request)
10
+ end
11
+
12
+ # Catching the response
13
+ def on_after_response(response)
14
+ @response = response
15
+ end
16
+ end
17
+
18
+
19
+
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: test-words-api-client-sdk
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sufyan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-10-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: apimatic_core_interfaces
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: apimatic_core
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.3.9
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.3.9
41
+ - !ruby/object:Gem::Dependency
42
+ name: apimatic_faraday_client_adapter
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.1.4
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.1.4
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 5.24.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 5.24.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest-proveit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ description: Words API lets you retrieve information about English words, including
84
+ definitions, synonyms, rhymes, pronunciation, syllables, and frequency of usage.
85
+ It also can tell you about relationships between words, for instance that “math”
86
+ has categories like “algebra” and “geometry”, or that a “finger” is part of a “hand”.
87
+ email: []
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - LICENSE
93
+ - README.md
94
+ - lib/words_api.rb
95
+ - lib/words_api/api_helper.rb
96
+ - lib/words_api/client.rb
97
+ - lib/words_api/configuration.rb
98
+ - lib/words_api/controllers/ap_is_controller.rb
99
+ - lib/words_api/controllers/base_controller.rb
100
+ - lib/words_api/exceptions/api_exception.rb
101
+ - lib/words_api/http/auth/custom_header_authentication.rb
102
+ - lib/words_api/http/http_call_back.rb
103
+ - lib/words_api/http/http_method_enum.rb
104
+ - lib/words_api/http/http_request.rb
105
+ - lib/words_api/http/http_response.rb
106
+ - lib/words_api/models/base_model.rb
107
+ - lib/words_api/models/definitions_response.rb
108
+ - lib/words_api/models/examples_response.rb
109
+ - lib/words_api/models/frequency_details.rb
110
+ - lib/words_api/models/frequency_response.rb
111
+ - lib/words_api/models/pronunciation_details.rb
112
+ - lib/words_api/models/pronunciation_response.rb
113
+ - lib/words_api/models/syllable_details.rb
114
+ - lib/words_api/models/synonyms_response.rb
115
+ - lib/words_api/models/word_details.rb
116
+ - lib/words_api/models/word_response.rb
117
+ - lib/words_api/utilities/date_time_helper.rb
118
+ - lib/words_api/utilities/file_wrapper.rb
119
+ - test/controllers/controller_test_base.rb
120
+ - test/controllers/test_ap_is_controller.rb
121
+ - test/http_response_catcher.rb
122
+ homepage: https://apimatic.io
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '2.6'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">="
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubygems_version: 3.1.6
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: Words API lets you retrieve information about English words, including definitions,
145
+ synonyms, rhymes, pronunciation, syllables, and frequency of usage.
146
+ test_files: []