zahra-package-test 1.1.2

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 (44) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +112 -0
  4. data/lib/swagger_petstore/api_helper.rb +10 -0
  5. data/lib/swagger_petstore/client.rb +84 -0
  6. data/lib/swagger_petstore/configuration.rb +124 -0
  7. data/lib/swagger_petstore/controllers/base_controller.rb +66 -0
  8. data/lib/swagger_petstore/controllers/pet_controller.rb +206 -0
  9. data/lib/swagger_petstore/controllers/store_controller.rb +94 -0
  10. data/lib/swagger_petstore/controllers/user_controller.rb +165 -0
  11. data/lib/swagger_petstore/exceptions/api_exception.rb +10 -0
  12. data/lib/swagger_petstore/exceptions/o_auth_provider_exception.rb +48 -0
  13. data/lib/swagger_petstore/http/auth/api_key.rb +42 -0
  14. data/lib/swagger_petstore/http/auth/http_basic.rb +50 -0
  15. data/lib/swagger_petstore/http/auth/petstore_auth.rb +91 -0
  16. data/lib/swagger_petstore/http/http_call_back.rb +10 -0
  17. data/lib/swagger_petstore/http/http_method_enum.rb +10 -0
  18. data/lib/swagger_petstore/http/http_request.rb +10 -0
  19. data/lib/swagger_petstore/http/http_response.rb +10 -0
  20. data/lib/swagger_petstore/models/api_response.rb +70 -0
  21. data/lib/swagger_petstore/models/base_model.rb +62 -0
  22. data/lib/swagger_petstore/models/category.rb +60 -0
  23. data/lib/swagger_petstore/models/category2.rb +60 -0
  24. data/lib/swagger_petstore/models/content_type_enum.rb +20 -0
  25. data/lib/swagger_petstore/models/o_auth_provider_error_enum.rb +45 -0
  26. data/lib/swagger_petstore/models/o_auth_scope_petstore_auth_enum.rb +23 -0
  27. data/lib/swagger_petstore/models/o_auth_token.rb +100 -0
  28. data/lib/swagger_petstore/models/order.rb +109 -0
  29. data/lib/swagger_petstore/models/pet.rb +107 -0
  30. data/lib/swagger_petstore/models/pet_request.rb +107 -0
  31. data/lib/swagger_petstore/models/status1_enum.rb +26 -0
  32. data/lib/swagger_petstore/models/status2_enum.rb +26 -0
  33. data/lib/swagger_petstore/models/status_enum.rb +26 -0
  34. data/lib/swagger_petstore/models/store_order_request.rb +109 -0
  35. data/lib/swagger_petstore/models/tag.rb +60 -0
  36. data/lib/swagger_petstore/models/user.rb +120 -0
  37. data/lib/swagger_petstore/models/user_request.rb +120 -0
  38. data/lib/swagger_petstore/utilities/date_time_helper.rb +11 -0
  39. data/lib/swagger_petstore/utilities/file_wrapper.rb +16 -0
  40. data/lib/swagger_petstore.rb +61 -0
  41. data/test/controllers/controller_test_base.rb +38 -0
  42. data/test/controllers/test_store_controller.rb +32 -0
  43. data/test/http_response_catcher.rb +19 -0
  44. metadata +160 -0
@@ -0,0 +1,26 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SwaggerPetstore
7
+ # pet status in the store
8
+ class StatusEnum
9
+ STATUS_ENUM = [
10
+ # TODO: Write general description for AVAILABLE
11
+ AVAILABLE = 'available'.freeze,
12
+
13
+ # TODO: Write general description for PENDING
14
+ PENDING = 'pending'.freeze,
15
+
16
+ # TODO: Write general description for SOLD
17
+ SOLD = 'sold'.freeze
18
+ ].freeze
19
+
20
+ def self.validate(value)
21
+ return false if value.nil?
22
+
23
+ STATUS_ENUM.include?(value)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,109 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'date'
7
+ module SwaggerPetstore
8
+ # StoreOrderRequest Model.
9
+ class StoreOrderRequest < BaseModel
10
+ SKIP = Object.new
11
+ private_constant :SKIP
12
+
13
+ # TODO: Write general description for this method
14
+ # @return [Integer]
15
+ attr_accessor :id
16
+
17
+ # TODO: Write general description for this method
18
+ # @return [Integer]
19
+ attr_accessor :pet_id
20
+
21
+ # TODO: Write general description for this method
22
+ # @return [Integer]
23
+ attr_accessor :quantity
24
+
25
+ # TODO: Write general description for this method
26
+ # @return [DateTime]
27
+ attr_accessor :ship_date
28
+
29
+ # TODO: Write general description for this method
30
+ # @return [Status1Enum]
31
+ attr_accessor :status
32
+
33
+ # TODO: Write general description for this method
34
+ # @return [TrueClass | FalseClass]
35
+ attr_accessor :complete
36
+
37
+ # A mapping from model property names to API property names.
38
+ def self.names
39
+ @_hash = {} if @_hash.nil?
40
+ @_hash['id'] = 'id'
41
+ @_hash['pet_id'] = 'petId'
42
+ @_hash['quantity'] = 'quantity'
43
+ @_hash['ship_date'] = 'shipDate'
44
+ @_hash['status'] = 'status'
45
+ @_hash['complete'] = 'complete'
46
+ @_hash
47
+ end
48
+
49
+ # An array for optional fields
50
+ def self.optionals
51
+ %w[
52
+ id
53
+ pet_id
54
+ quantity
55
+ ship_date
56
+ status
57
+ complete
58
+ ]
59
+ end
60
+
61
+ # An array for nullable fields
62
+ def self.nullables
63
+ []
64
+ end
65
+
66
+ def initialize(id = SKIP,
67
+ pet_id = SKIP,
68
+ quantity = SKIP,
69
+ ship_date = SKIP,
70
+ status = SKIP,
71
+ complete = SKIP)
72
+ @id = id unless id == SKIP
73
+ @pet_id = pet_id unless pet_id == SKIP
74
+ @quantity = quantity unless quantity == SKIP
75
+ @ship_date = ship_date unless ship_date == SKIP
76
+ @status = status unless status == SKIP
77
+ @complete = complete unless complete == SKIP
78
+ end
79
+
80
+ # Creates an instance of the object from a hash.
81
+ def self.from_hash(hash)
82
+ return nil unless hash
83
+
84
+ # Extract variables from the hash.
85
+ id = hash.key?('id') ? hash['id'] : SKIP
86
+ pet_id = hash.key?('petId') ? hash['petId'] : SKIP
87
+ quantity = hash.key?('quantity') ? hash['quantity'] : SKIP
88
+ ship_date = if hash.key?('shipDate')
89
+ (DateTimeHelper.from_rfc3339(hash['shipDate']) if hash['shipDate'])
90
+ else
91
+ SKIP
92
+ end
93
+ status = hash.key?('status') ? hash['status'] : SKIP
94
+ complete = hash.key?('complete') ? hash['complete'] : SKIP
95
+
96
+ # Create object from extracted values.
97
+ StoreOrderRequest.new(id,
98
+ pet_id,
99
+ quantity,
100
+ ship_date,
101
+ status,
102
+ complete)
103
+ end
104
+
105
+ def to_custom_ship_date
106
+ DateTimeHelper.to_rfc3339(ship_date)
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,60 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SwaggerPetstore
7
+ # Tag Model.
8
+ class Tag < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [Integer]
14
+ attr_accessor :id
15
+
16
+ # TODO: Write general description for this method
17
+ # @return [String]
18
+ attr_accessor :name
19
+
20
+ # A mapping from model property names to API property names.
21
+ def self.names
22
+ @_hash = {} if @_hash.nil?
23
+ @_hash['id'] = 'id'
24
+ @_hash['name'] = 'name'
25
+ @_hash
26
+ end
27
+
28
+ # An array for optional fields
29
+ def self.optionals
30
+ %w[
31
+ id
32
+ name
33
+ ]
34
+ end
35
+
36
+ # An array for nullable fields
37
+ def self.nullables
38
+ []
39
+ end
40
+
41
+ def initialize(id = SKIP,
42
+ name = SKIP)
43
+ @id = id unless id == SKIP
44
+ @name = name unless name == SKIP
45
+ end
46
+
47
+ # Creates an instance of the object from a hash.
48
+ def self.from_hash(hash)
49
+ return nil unless hash
50
+
51
+ # Extract variables from the hash.
52
+ id = hash.key?('id') ? hash['id'] : SKIP
53
+ name = hash.key?('name') ? hash['name'] : SKIP
54
+
55
+ # Create object from extracted values.
56
+ Tag.new(id,
57
+ name)
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,120 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SwaggerPetstore
7
+ # User Model.
8
+ class User < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [Integer]
14
+ attr_accessor :id
15
+
16
+ # TODO: Write general description for this method
17
+ # @return [String]
18
+ attr_accessor :username
19
+
20
+ # TODO: Write general description for this method
21
+ # @return [String]
22
+ attr_accessor :first_name
23
+
24
+ # TODO: Write general description for this method
25
+ # @return [String]
26
+ attr_accessor :last_name
27
+
28
+ # TODO: Write general description for this method
29
+ # @return [String]
30
+ attr_accessor :email
31
+
32
+ # TODO: Write general description for this method
33
+ # @return [String]
34
+ attr_accessor :password
35
+
36
+ # TODO: Write general description for this method
37
+ # @return [String]
38
+ attr_accessor :phone
39
+
40
+ # User Status
41
+ # @return [Integer]
42
+ attr_accessor :user_status
43
+
44
+ # A mapping from model property names to API property names.
45
+ def self.names
46
+ @_hash = {} if @_hash.nil?
47
+ @_hash['id'] = 'id'
48
+ @_hash['username'] = 'username'
49
+ @_hash['first_name'] = 'firstName'
50
+ @_hash['last_name'] = 'lastName'
51
+ @_hash['email'] = 'email'
52
+ @_hash['password'] = 'password'
53
+ @_hash['phone'] = 'phone'
54
+ @_hash['user_status'] = 'userStatus'
55
+ @_hash
56
+ end
57
+
58
+ # An array for optional fields
59
+ def self.optionals
60
+ %w[
61
+ id
62
+ username
63
+ first_name
64
+ last_name
65
+ email
66
+ password
67
+ phone
68
+ user_status
69
+ ]
70
+ end
71
+
72
+ # An array for nullable fields
73
+ def self.nullables
74
+ []
75
+ end
76
+
77
+ def initialize(id = SKIP,
78
+ username = SKIP,
79
+ first_name = SKIP,
80
+ last_name = SKIP,
81
+ email = SKIP,
82
+ password = SKIP,
83
+ phone = SKIP,
84
+ user_status = SKIP)
85
+ @id = id unless id == SKIP
86
+ @username = username unless username == SKIP
87
+ @first_name = first_name unless first_name == SKIP
88
+ @last_name = last_name unless last_name == SKIP
89
+ @email = email unless email == SKIP
90
+ @password = password unless password == SKIP
91
+ @phone = phone unless phone == SKIP
92
+ @user_status = user_status unless user_status == SKIP
93
+ end
94
+
95
+ # Creates an instance of the object from a hash.
96
+ def self.from_hash(hash)
97
+ return nil unless hash
98
+
99
+ # Extract variables from the hash.
100
+ id = hash.key?('id') ? hash['id'] : SKIP
101
+ username = hash.key?('username') ? hash['username'] : SKIP
102
+ first_name = hash.key?('firstName') ? hash['firstName'] : SKIP
103
+ last_name = hash.key?('lastName') ? hash['lastName'] : SKIP
104
+ email = hash.key?('email') ? hash['email'] : SKIP
105
+ password = hash.key?('password') ? hash['password'] : SKIP
106
+ phone = hash.key?('phone') ? hash['phone'] : SKIP
107
+ user_status = hash.key?('userStatus') ? hash['userStatus'] : SKIP
108
+
109
+ # Create object from extracted values.
110
+ User.new(id,
111
+ username,
112
+ first_name,
113
+ last_name,
114
+ email,
115
+ password,
116
+ phone,
117
+ user_status)
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,120 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SwaggerPetstore
7
+ # UserRequest Model.
8
+ class UserRequest < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # TODO: Write general description for this method
13
+ # @return [Integer]
14
+ attr_accessor :id
15
+
16
+ # TODO: Write general description for this method
17
+ # @return [String]
18
+ attr_accessor :username
19
+
20
+ # TODO: Write general description for this method
21
+ # @return [String]
22
+ attr_accessor :first_name
23
+
24
+ # TODO: Write general description for this method
25
+ # @return [String]
26
+ attr_accessor :last_name
27
+
28
+ # TODO: Write general description for this method
29
+ # @return [String]
30
+ attr_accessor :email
31
+
32
+ # TODO: Write general description for this method
33
+ # @return [String]
34
+ attr_accessor :password
35
+
36
+ # TODO: Write general description for this method
37
+ # @return [String]
38
+ attr_accessor :phone
39
+
40
+ # User Status
41
+ # @return [Integer]
42
+ attr_accessor :user_status
43
+
44
+ # A mapping from model property names to API property names.
45
+ def self.names
46
+ @_hash = {} if @_hash.nil?
47
+ @_hash['id'] = 'id'
48
+ @_hash['username'] = 'username'
49
+ @_hash['first_name'] = 'firstName'
50
+ @_hash['last_name'] = 'lastName'
51
+ @_hash['email'] = 'email'
52
+ @_hash['password'] = 'password'
53
+ @_hash['phone'] = 'phone'
54
+ @_hash['user_status'] = 'userStatus'
55
+ @_hash
56
+ end
57
+
58
+ # An array for optional fields
59
+ def self.optionals
60
+ %w[
61
+ id
62
+ username
63
+ first_name
64
+ last_name
65
+ email
66
+ password
67
+ phone
68
+ user_status
69
+ ]
70
+ end
71
+
72
+ # An array for nullable fields
73
+ def self.nullables
74
+ []
75
+ end
76
+
77
+ def initialize(id = SKIP,
78
+ username = SKIP,
79
+ first_name = SKIP,
80
+ last_name = SKIP,
81
+ email = SKIP,
82
+ password = SKIP,
83
+ phone = SKIP,
84
+ user_status = SKIP)
85
+ @id = id unless id == SKIP
86
+ @username = username unless username == SKIP
87
+ @first_name = first_name unless first_name == SKIP
88
+ @last_name = last_name unless last_name == SKIP
89
+ @email = email unless email == SKIP
90
+ @password = password unless password == SKIP
91
+ @phone = phone unless phone == SKIP
92
+ @user_status = user_status unless user_status == SKIP
93
+ end
94
+
95
+ # Creates an instance of the object from a hash.
96
+ def self.from_hash(hash)
97
+ return nil unless hash
98
+
99
+ # Extract variables from the hash.
100
+ id = hash.key?('id') ? hash['id'] : SKIP
101
+ username = hash.key?('username') ? hash['username'] : SKIP
102
+ first_name = hash.key?('firstName') ? hash['firstName'] : SKIP
103
+ last_name = hash.key?('lastName') ? hash['lastName'] : SKIP
104
+ email = hash.key?('email') ? hash['email'] : SKIP
105
+ password = hash.key?('password') ? hash['password'] : SKIP
106
+ phone = hash.key?('phone') ? hash['phone'] : SKIP
107
+ user_status = hash.key?('userStatus') ? hash['userStatus'] : SKIP
108
+
109
+ # Create object from extracted values.
110
+ UserRequest.new(id,
111
+ username,
112
+ first_name,
113
+ last_name,
114
+ email,
115
+ password,
116
+ phone,
117
+ user_status)
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,11 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ require 'date'
7
+ module SwaggerPetstore
8
+ # A utility that supports dateTime conversion to different formats
9
+ class DateTimeHelper < CoreLibrary::DateTimeHelper
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module SwaggerPetstore
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
@@ -0,0 +1,61 @@
1
+ # swagger_petstore
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 'swagger_petstore/api_helper'
14
+ require_relative 'swagger_petstore/client'
15
+
16
+ # Utilities
17
+ require_relative 'swagger_petstore/utilities/file_wrapper'
18
+ require_relative 'swagger_petstore/utilities/date_time_helper'
19
+
20
+ # Http
21
+ require_relative 'swagger_petstore/http/http_call_back'
22
+ require_relative 'swagger_petstore/http/http_method_enum'
23
+ require_relative 'swagger_petstore/http/http_request'
24
+ require_relative 'swagger_petstore/http/http_response'
25
+
26
+ # Logger
27
+ require_relative 'swagger_petstore/http/auth/api_key'
28
+ require_relative 'swagger_petstore/http/auth/http_basic'
29
+ require_relative 'swagger_petstore/http/auth/petstore_auth'
30
+
31
+ # Models
32
+ require_relative 'swagger_petstore/models/base_model'
33
+ require_relative 'swagger_petstore/models/pet'
34
+ require_relative 'swagger_petstore/models/category'
35
+ require_relative 'swagger_petstore/models/api_response'
36
+ require_relative 'swagger_petstore/models/pet_request'
37
+ require_relative 'swagger_petstore/models/category2'
38
+ require_relative 'swagger_petstore/models/store_order_request'
39
+ require_relative 'swagger_petstore/models/order'
40
+ require_relative 'swagger_petstore/models/tag'
41
+ require_relative 'swagger_petstore/models/user'
42
+ require_relative 'swagger_petstore/models/user_request'
43
+ require_relative 'swagger_petstore/models/o_auth_token'
44
+ require_relative 'swagger_petstore/models/content_type_enum'
45
+ require_relative 'swagger_petstore/models/status2_enum'
46
+ require_relative 'swagger_petstore/models/status1_enum'
47
+ require_relative 'swagger_petstore/models/status_enum'
48
+ require_relative 'swagger_petstore/models/o_auth_provider_error_enum'
49
+ require_relative 'swagger_petstore/models/o_auth_scope_petstore_auth_enum'
50
+
51
+ # Exceptions
52
+ require_relative 'swagger_petstore/exceptions/api_exception'
53
+ require_relative 'swagger_petstore/exceptions/o_auth_provider_exception'
54
+
55
+ require_relative 'swagger_petstore/configuration'
56
+
57
+ # Controllers
58
+ require_relative 'swagger_petstore/controllers/base_controller'
59
+ require_relative 'swagger_petstore/controllers/pet_controller'
60
+ require_relative 'swagger_petstore/controllers/store_controller'
61
+ require_relative 'swagger_petstore/controllers/user_controller'
@@ -0,0 +1,38 @@
1
+ # swagger_petstore
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 'swagger_petstore'
12
+ require_relative '../http_response_catcher'
13
+
14
+ class ControllerTestBase < Minitest::Test
15
+ parallelize_me!
16
+ include SwaggerPetstore
17
+ include CoreLibrary
18
+
19
+ # Create configuration and set any test parameters
20
+ def create_configuration
21
+ Configuration.new(
22
+ http_basic_credentials: HttpBasicCredentials.new(username: 'test',
23
+ passwprd: 'testPassword'),
24
+ http_callback: HttpResponseCatcher.new
25
+ )
26
+ end
27
+
28
+ # Initializes the base test controller
29
+ def setup_class
30
+ _config = create_configuration
31
+ @client = Client.new(config: _config)
32
+
33
+ petstore_auth_token = @client.petstore_auth.fetch_token()
34
+ petstore_auth_credentials = _config.petstore_auth_credentials.clone_with(o_auth_token: petstore_auth_token)
35
+ _config = _config.clone_with(petstore_auth_credentials: petstore_auth_credentials)
36
+ @client = Client.new(config: _config)
37
+ end
38
+ end
@@ -0,0 +1,32 @@
1
+ # swagger_petstore
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 StoreControllerTests < ControllerTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ setup_class
12
+ @controller = @client.store
13
+ @response_catcher = @controller.http_call_back
14
+ end
15
+
16
+ # Returns a map of status codes to quantities
17
+ def test_get_inventory
18
+
19
+ # Perform the API call through the SDK function
20
+ result = @controller.get_inventory()
21
+
22
+ # Test response code
23
+ assert_equal(200, @response_catcher.response.status_code)
24
+
25
+ # Test headers
26
+ expected_headers = {}
27
+ expected_headers['content-type'] = 'application/json'
28
+
29
+ assert(ComparisonHelper.match_headers(expected_headers, @response_catcher.response.headers))
30
+ end
31
+
32
+ end
@@ -0,0 +1,19 @@
1
+ # swagger_petstore
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ class HttpResponseCatcher < SwaggerPetstore::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
+