noths 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +2 -2
  3. data/README.md +10 -23
  4. data/bin/generate_gem +3 -1
  5. data/bin/refresh_schemas +22 -16
  6. data/docs/AcceptanceBulkModel.md +2 -2
  7. data/docs/DispatchBulkModel.md +1 -1
  8. data/docs/Financials.md +1 -1
  9. data/docs/Order.md +12 -11
  10. data/docs/OrdersApi.md +104 -151
  11. data/docs/RefundsApi.md +8 -12
  12. data/git_push.sh +55 -0
  13. data/lib/noths.rb +1 -11
  14. data/lib/noths/api/orders_api.rb +234 -114
  15. data/lib/noths/api/refunds_api.rb +25 -15
  16. data/lib/noths/api_client.rb +3 -12
  17. data/lib/noths/api_error.rb +16 -11
  18. data/lib/noths/configuration.rb +3 -20
  19. data/lib/noths/models/acceptance_bulk_model.rb +3 -14
  20. data/lib/noths/models/currency.rb +1 -12
  21. data/lib/noths/models/decline_bulk_model.rb +1 -12
  22. data/lib/noths/models/delivery_address.rb +1 -12
  23. data/lib/noths/models/delivery_service.rb +1 -12
  24. data/lib/noths/models/delivery_zone.rb +1 -12
  25. data/lib/noths/models/dispatch_bulk_model.rb +2 -13
  26. data/lib/noths/models/dispatch_notes_bulk_model.rb +1 -12
  27. data/lib/noths/models/enquiry.rb +1 -12
  28. data/lib/noths/models/enquiry_message.rb +1 -12
  29. data/lib/noths/models/error.rb +1 -12
  30. data/lib/noths/models/financials.rb +5 -14
  31. data/lib/noths/models/financials_details.rb +1 -12
  32. data/lib/noths/models/image_url.rb +1 -12
  33. data/lib/noths/models/item.rb +1 -12
  34. data/lib/noths/models/item_financials.rb +1 -12
  35. data/lib/noths/models/link.rb +1 -12
  36. data/lib/noths/models/manual_payment.rb +1 -12
  37. data/lib/noths/models/money.rb +1 -12
  38. data/lib/noths/models/order.rb +28 -28
  39. data/lib/noths/models/order_detail.rb +1 -12
  40. data/lib/noths/models/order_details_bulk_model.rb +1 -12
  41. data/lib/noths/models/order_index.rb +1 -12
  42. data/lib/noths/models/order_refund.rb +1 -12
  43. data/lib/noths/models/product.rb +1 -12
  44. data/lib/noths/models/product_option.rb +1 -12
  45. data/lib/noths/models/refund_response.rb +1 -12
  46. data/lib/noths/models/search_result_meta.rb +1 -12
  47. data/lib/noths/models/user.rb +1 -12
  48. data/lib/noths/version.rb +2 -12
  49. data/noths.gemspec +1 -11
  50. data/schemas/api-docs.json +3 -7
  51. data/schemas/orders.json +163 -88
  52. data/schemas/refunds.json +10 -5
  53. data/spec/api/orders_api_spec.rb +53 -99
  54. data/spec/api/refunds_api_spec.rb +6 -28
  55. data/spec/api_client_spec.rb +2 -14
  56. data/spec/configuration_spec.rb +9 -25
  57. data/spec/models/acceptance_bulk_model_spec.rb +7 -38
  58. data/spec/models/currency_spec.rb +7 -38
  59. data/spec/models/decline_bulk_model_spec.rb +5 -32
  60. data/spec/models/delivery_address_spec.rb +9 -44
  61. data/spec/models/delivery_service_spec.rb +5 -32
  62. data/spec/models/delivery_zone_spec.rb +5 -32
  63. data/spec/models/dispatch_bulk_model_spec.rb +8 -41
  64. data/spec/models/dispatch_notes_bulk_model_spec.rb +4 -29
  65. data/spec/models/enquiry_message_spec.rb +4 -29
  66. data/spec/models/enquiry_spec.rb +6 -35
  67. data/spec/models/error_spec.rb +5 -32
  68. data/spec/models/financials_details_spec.rb +6 -35
  69. data/spec/models/financials_spec.rb +21 -80
  70. data/spec/models/image_url_spec.rb +9 -44
  71. data/spec/models/item_financials_spec.rb +9 -44
  72. data/spec/models/item_spec.rb +11 -50
  73. data/spec/models/link_spec.rb +6 -35
  74. data/spec/models/manual_payment_spec.rb +7 -38
  75. data/spec/models/money_spec.rb +5 -32
  76. data/spec/models/order_detail_spec.rb +5 -32
  77. data/spec/models/order_details_bulk_model_spec.rb +4 -29
  78. data/spec/models/order_index_spec.rb +6 -35
  79. data/spec/models/order_refund_spec.rb +4 -29
  80. data/spec/models/order_spec.rb +53 -164
  81. data/spec/models/product_option_spec.rb +5 -32
  82. data/spec/models/product_spec.rb +8 -41
  83. data/spec/models/refund_response_spec.rb +6 -35
  84. data/spec/models/search_result_meta_spec.rb +5 -32
  85. data/spec/models/user_spec.rb +6 -35
  86. data/spec/spec_helper.rb +1 -11
  87. data/swagger_config.json +1 -1
  88. data/templates/Gemfile.mustache +7 -0
  89. data/templates/README.mustache +127 -0
  90. data/templates/Rakefile.mustache +8 -0
  91. data/templates/api.mustache +194 -0
  92. data/templates/api_client.mustache +383 -0
  93. data/templates/api_client_spec.mustache +214 -0
  94. data/templates/api_doc.mustache +79 -0
  95. data/templates/api_error.mustache +43 -0
  96. data/templates/api_info.mustache +12 -0
  97. data/templates/api_test.mustache +29 -0
  98. data/templates/base_object.mustache +102 -0
  99. data/templates/base_object_spec.mustache +107 -0
  100. data/templates/configuration.mustache +221 -0
  101. data/templates/configuration_spec.mustache +26 -0
  102. data/templates/gem.mustache +38 -0
  103. data/templates/gemspec.mustache +41 -0
  104. data/templates/git_push.sh.mustache +55 -0
  105. data/templates/gitignore.mustache +35 -0
  106. data/templates/model.mustache +7 -0
  107. data/templates/model_doc.mustache +9 -0
  108. data/templates/model_test.mustache +19 -0
  109. data/templates/partial_model_enum_class.mustache +13 -0
  110. data/templates/partial_model_generic.mustache +275 -0
  111. data/templates/rspec.mustache +2 -0
  112. data/templates/spec_helper.mustache +101 -0
  113. data/templates/version.mustache +5 -0
  114. metadata +30 -3
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe {{moduleName}}::Configuration do
4
+ let(:config) { {{moduleName}}::Configuration.default }
5
+
6
+ before do
7
+ {{moduleName}}.configure do |c|
8
+ c.scheme = 'https'
9
+ c.host = 'api.example.com'
10
+ c.base_path = '/v1'
11
+ end
12
+ end
13
+
14
+ describe '#base_url' do
15
+ it 'should have the default value' do
16
+ expect(config.base_url).to eq("https://api.example.com/v1")
17
+ end
18
+
19
+ it 'should remove trailing slashes' do
20
+ [nil, '', '/', '//'].each do |base_path|
21
+ config.base_path = base_path
22
+ expect(config.base_url).to eq("https://api.example.com")
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Common files
4
+ require '{{gemName}}/api_client'
5
+ require '{{gemName}}/api_error'
6
+ require '{{gemName}}/version'
7
+ require '{{gemName}}/configuration'
8
+
9
+ # Models
10
+ {{#models}}
11
+ {{#model}}
12
+ require '{{gemName}}/{{modelPackage}}/{{classFilename}}'{{/model}}
13
+ {{/models}}
14
+
15
+ # APIs
16
+ {{#apiInfo}}
17
+ {{#apis}}
18
+ require '{{importPath}}'
19
+ {{/apis}}
20
+ {{/apiInfo}}
21
+
22
+ module {{moduleName}}
23
+ class << self
24
+ # Customize default settings for the SDK using block.
25
+ # {{moduleName}}.configure do |config|
26
+ # config.username = "xxx"
27
+ # config.password = "xxx"
28
+ # end
29
+ # If no block given, return the default Configuration object.
30
+ def configure
31
+ if block_given?
32
+ yield(Configuration.default)
33
+ else
34
+ Configuration.default
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,41 @@
1
+ # -*- encoding: utf-8 -*-
2
+ #
3
+ # frozen_string_literal: true
4
+
5
+ $:.push File.expand_path("../lib", __FILE__)
6
+ require "{{gemName}}/version"
7
+
8
+ Gem::Specification.new do |s|
9
+ s.name = "{{gemName}}{{^gemName}}{{{appName}}}{{/gemName}}"
10
+ s.version = {{moduleName}}::VERSION
11
+ s.platform = Gem::Platform::RUBY
12
+ s.authors = ["{{gemAuthor}}{{^gemAuthor}}Swagger-Codegen{{/gemAuthor}}"]
13
+ s.email = ["{{gemAuthorEmail}}{{^gemAuthorEmail}}{{infoEmail}}{{/gemAuthorEmail}}"]
14
+ s.homepage = "{{gemHomepage}}{{^gemHomepage}}https://github.com/swagger-api/swagger-codegen{{/gemHomepage}}"
15
+ s.summary = "{{gemSummary}}{{^gemSummary}}{{{appName}}} Ruby Gem{{/gemSummary}}"
16
+ s.description = "{{gemDescription}}{{^gemDescription}}{{{appDescription}}}{{^appDescription}}{{{appName}}} Ruby Gem{{/appDescription}}{{/gemDescription}}"
17
+ {{#gemLicense}}
18
+ s.license = "{{{gemLicense}}}"
19
+ {{/gemLicense}}
20
+ {{^gemLicense}}
21
+ # TODO uncommnet and update below with a proper license
22
+ #s.license = "Apache 2.0"
23
+ {{/gemLicense}}
24
+ s.required_ruby_version = "{{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}>= 1.9{{/gemRequiredRubyVersion}}"
25
+
26
+ s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
27
+ s.add_runtime_dependency 'json', '~> 2.1', '>= 2.1.0'
28
+
29
+ s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
30
+ s.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.1'
31
+ s.add_development_dependency 'webmock', '~> 1.24', '>= 1.24.3'
32
+ s.add_development_dependency 'autotest', '~> 4.4', '>= 4.4.6'
33
+ s.add_development_dependency 'autotest-rails-pure', '~> 4.1', '>= 4.1.2'
34
+ s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16'
35
+ s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.12'
36
+
37
+ s.files = `find *`.split("\n").uniq.sort.select{|f| !f.empty? }
38
+ s.test_files = `find spec/*`.split("\n")
39
+ s.executables = []
40
+ s.require_paths = ["lib"]
41
+ end
@@ -0,0 +1,55 @@
1
+ #!/bin/sh
2
+ #
3
+ # Generated by: https://github.com/swagger-api/swagger-codegen.git
4
+ #
5
+ # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
6
+ #
7
+ # Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
8
+
9
+ git_user_id=$1
10
+ git_repo_id=$2
11
+ release_note=$3
12
+
13
+ if [ "$git_user_id" = "" ]; then
14
+ git_user_id="{{{gitUserId}}}"
15
+ echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
16
+ fi
17
+
18
+ if [ "$git_repo_id" = "" ]; then
19
+ git_repo_id="{{{gitRepoId}}}"
20
+ echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
21
+ fi
22
+
23
+ if [ "$release_note" = "" ]; then
24
+ release_note="{{{releaseNote}}}"
25
+ echo "[INFO] No command line input provided. Set \$release_note to $release_note"
26
+ fi
27
+
28
+ # Initialize the local directory as a Git repository
29
+ git init
30
+
31
+ # Adds the files in the local repository and stages them for commit.
32
+ git add .
33
+
34
+ # Commits the tracked changes and prepares them to be pushed to a remote repository.
35
+ git commit -m "$release_note"
36
+
37
+ # Sets the new remote
38
+ git_remote=`git remote`
39
+ if [ "$git_remote" = "" ]; then # git remote not defined
40
+
41
+ if [ "$GIT_TOKEN" = "" ]; then
42
+ echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
43
+ git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
44
+ else
45
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
46
+ fi
47
+
48
+ fi
49
+
50
+ git pull origin master
51
+
52
+ # Pushes (Forces) the changes in the local repository up to the remote repository
53
+ echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
54
+ git push origin master 2>&1 | grep -v 'To https'
55
+
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ ## Specific to RubyMotion:
14
+ .dat*
15
+ .repl_history
16
+ build/
17
+
18
+ ## Documentation cache and generated files:
19
+ /.yardoc/
20
+ /_yardoc/
21
+ /doc/
22
+ /rdoc/
23
+
24
+ ## Environment normalization:
25
+ /.bundle/
26
+ /vendor/bundle
27
+ /lib/bundler/man/
28
+
29
+ # for a library or gem, you might want to ignore these files since the code is
30
+ # intended to run in multiple environments; otherwise, check them in:
31
+ Gemfile.lock
32
+ .ruby-version
33
+ .ruby-gemset
34
+
35
+ .DS_Store
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'date'
4
+
5
+ module {{moduleName}}
6
+ {{#models}}{{#model}}{{#isEnum}}{{>partial_model_enum_class}}{{/isEnum}}{{^isEnum}}{{>partial_model_generic}}{{/isEnum}}{{/model}}{{/models}}
7
+ end
@@ -0,0 +1,9 @@
1
+ {{#models}}{{#model}}# {{moduleName}}::{{classname}}
2
+
3
+ ## Properties
4
+ Name | Type | Description | Notes
5
+ ------------ | ------------- | ------------- | -------------
6
+ {{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{datatype}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{datatype}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#readOnly}}[readonly] {{/readOnly}}{{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}
7
+ {{/vars}}
8
+
9
+ {{/model}}{{/models}}
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Unit tests for {{moduleName}}::{{classname}}
4
+ {{#models}}{{#model}}describe '{{classname}}' do
5
+ let(:instance) { {{moduleName}}::{{classname}}.new }
6
+
7
+ describe 'test an instance of {{classname}}' do
8
+ it 'should create an instance of {{classname}}' do
9
+ expect(instance).to be_instance_of({{moduleName}}::{{classname}})
10
+ end
11
+ end
12
+ {{#vars}}
13
+ describe 'test attribute "{{{name}}}"' do
14
+ it 'should work'
15
+ end
16
+
17
+ {{/vars}}
18
+ end
19
+ {{/model}}{{/models}}
@@ -0,0 +1,13 @@
1
+ class {{classname}}
2
+ {{#allowableValues}}{{#enumVars}}
3
+ {{{name}}} = {{{value}}}.freeze{{/enumVars}}{{/allowableValues}}
4
+
5
+ # Builds the enum from string
6
+ # @param [String] The enum value in the form of the string
7
+ # @return [String] The enum value
8
+ def build_from_hash(value)
9
+ constantValues = {{classname}}.constants.select{|c| {{classname}}::const_get(c) == value}
10
+ raise "Invalid ENUM value #{value} for class #{{{classname}}}" if constantValues.empty?
11
+ value
12
+ end
13
+ end
@@ -0,0 +1,275 @@
1
+ {{#description}} # {{{description}}}{{/description}}
2
+ class {{classname}}{{#vars}}{{#description}}
3
+ # {{{description}}}{{/description}}
4
+ attr_accessor :{{{name}}}
5
+ {{/vars}}
6
+
7
+ {{#hasEnums}}
8
+ class EnumAttributeValidator
9
+ attr_reader :datatype
10
+ attr_reader :allowable_values
11
+
12
+ def initialize(datatype, allowable_values)
13
+ @allowable_values = allowable_values.map do |value|
14
+ case datatype.to_s
15
+ when /Integer/i
16
+ value.to_i
17
+ when /Float/i
18
+ value.to_f
19
+ else
20
+ value
21
+ end
22
+ end
23
+ end
24
+
25
+ def valid?(value)
26
+ !value || allowable_values.include?(value)
27
+ end
28
+ end
29
+ {{/hasEnums}}
30
+
31
+ # Attribute mapping from ruby-style variable name to JSON key.
32
+ def self.attribute_map
33
+ {
34
+ {{#vars}}
35
+ :'{{{name}}}' => :'{{{baseName}}}'{{#hasMore}},{{/hasMore}}
36
+ {{/vars}}
37
+ }
38
+ end
39
+
40
+ # Attribute type mapping.
41
+ def self.swagger_types
42
+ {
43
+ {{#vars}}
44
+ :'{{{name}}}' => :'{{{datatype}}}'{{#hasMore}},{{/hasMore}}
45
+ {{/vars}}
46
+ }
47
+ end
48
+
49
+ # Initializes the object
50
+ # @param [Hash] attributes Model attributes in the form of hash
51
+ def initialize(attributes = {})
52
+ return unless attributes.is_a?(Hash)
53
+
54
+ # convert string to symbol for hash key
55
+ attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
56
+
57
+ {{#vars}}
58
+ if attributes.has_key?(:'{{{baseName}}}')
59
+ {{#isListContainer}}
60
+ if (value = attributes[:'{{{baseName}}}']).is_a?(Array)
61
+ self.{{{name}}} = value
62
+ end
63
+ {{/isListContainer}}
64
+ {{#isMapContainer}}
65
+ if (value = attributes[:'{{{baseName}}}']).is_a?(Hash)
66
+ self.{{{name}}} = value
67
+ end
68
+ {{/isMapContainer}}
69
+ {{^isContainer}}
70
+ self.{{{name}}} = attributes[:'{{{baseName}}}']
71
+ {{/isContainer}}
72
+ {{#defaultValue}}
73
+ else
74
+ self.{{{name}}} = {{{defaultValue}}}
75
+ {{/defaultValue}}
76
+ end
77
+
78
+ {{/vars}}
79
+ end
80
+
81
+ # Show invalid properties with the reasons. Usually used together with valid?
82
+ # @return Array for valid properties with the reasons
83
+ def list_invalid_properties
84
+ invalid_properties = Array.new
85
+ {{#vars}}
86
+ {{#required}}
87
+ if @{{{name}}}.nil?
88
+ invalid_properties.push("invalid value for '{{{name}}}', {{{name}}} cannot be nil.")
89
+ end
90
+
91
+ {{/required}}
92
+ {{#hasValidation}}
93
+ {{#maxLength}}
94
+ if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length > {{{maxLength}}}
95
+ invalid_properties.push("invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}.")
96
+ end
97
+
98
+ {{/maxLength}}
99
+ {{#minLength}}
100
+ if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length < {{{minLength}}}
101
+ invalid_properties.push("invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}.")
102
+ end
103
+
104
+ {{/minLength}}
105
+ {{#maximum}}
106
+ if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}}
107
+ invalid_properties.push("invalid value for '{{{name}}}', must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}.")
108
+ end
109
+
110
+ {{/maximum}}
111
+ {{#minimum}}
112
+ if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}}
113
+ invalid_properties.push("invalid value for '{{{name}}}', must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}.")
114
+ end
115
+
116
+ {{/minimum}}
117
+ {{#pattern}}
118
+ if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} !~ Regexp.new({{{pattern}}})
119
+ invalid_properties.push("invalid value for '{{{name}}}', must conform to the pattern {{{pattern}}}.")
120
+ end
121
+
122
+ {{/pattern}}
123
+ {{#maxItems}}
124
+ if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length > {{{maxItems}}}
125
+ invalid_properties.push("invalid value for '{{{name}}}', number of items must be less than or equal to {{{maxItems}}}."
126
+ end
127
+
128
+ {{/maxItems}}
129
+ {{#minItems}}
130
+ if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length < {{{minItems}}}
131
+ invalid_properties.push("invalid value for '{{{name}}}', number of items must be greater than or equal to {{{minItems}}}."
132
+ end
133
+
134
+ {{/minItems}}
135
+ {{/hasValidation}}
136
+ {{/vars}}
137
+ return invalid_properties
138
+ end
139
+
140
+ # Check to see if the all the properties in the model are valid
141
+ # @return true if the model is valid
142
+ def valid?
143
+ {{#vars}}
144
+ {{#required}}
145
+ return false if @{{{name}}}.nil?
146
+ {{/required}}
147
+ {{#isEnum}}
148
+ {{^isContainer}}
149
+ {{{name}}}_validator = EnumAttributeValidator.new('{{{datatype}}}', [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}])
150
+ return false unless {{{name}}}_validator.valid?(@{{{name}}})
151
+ {{/isContainer}}
152
+ {{/isEnum}}
153
+ {{#hasValidation}}
154
+ {{#maxLength}}
155
+ return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length > {{{maxLength}}}
156
+ {{/maxLength}}
157
+ {{#minLength}}
158
+ return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length < {{{minLength}}}
159
+ {{/minLength}}
160
+ {{#maximum}}
161
+ return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}}
162
+ {{/maximum}}
163
+ {{#minimum}}
164
+ return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}}
165
+ {{/minimum}}
166
+ {{#pattern}}
167
+ return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} !~ Regexp.new({{{pattern}}})
168
+ {{/pattern}}
169
+ {{#maxItems}}
170
+ return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length > {{{maxItems}}}
171
+ {{/maxItems}}
172
+ {{#minItems}}
173
+ return false if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length < {{{minItems}}}
174
+ {{/minItems}}
175
+ {{/hasValidation}}
176
+ {{/vars}}
177
+ return true
178
+ end
179
+
180
+ {{#vars}}
181
+ {{#isEnum}}
182
+ {{^isContainer}}
183
+ # Custom attribute writer method checking allowed values (enum).
184
+ # @param [Object] {{{name}}} Object to be assigned
185
+ def {{{name}}}=({{{name}}})
186
+ validator = EnumAttributeValidator.new('{{{datatype}}}', [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}])
187
+ unless validator.valid?({{{name}}})
188
+ fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{validator.allowable_values}."
189
+ end
190
+ @{{{name}}} = {{{name}}}
191
+ end
192
+
193
+ {{/isContainer}}
194
+ {{/isEnum}}
195
+ {{^isEnum}}
196
+ {{#hasValidation}}
197
+ # Custom attribute writer method with validation
198
+ # @param [Object] {{{name}}} Value to be assigned
199
+ def {{{name}}}=({{{name}}})
200
+ {{#required}}
201
+ if {{{name}}}.nil?
202
+ fail ArgumentError, "{{{name}}} cannot be nil"
203
+ end
204
+ {{/required}}
205
+
206
+ {{#maxLength}}
207
+ if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.to_s.length > {{{maxLength}}}
208
+ fail ArgumentError, "invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}."
209
+ end
210
+
211
+ {{/maxLength}}
212
+ {{#minLength}}
213
+ if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.to_s.length < {{{minLength}}}
214
+ fail ArgumentError, "invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}."
215
+ end
216
+
217
+ {{/minLength}}
218
+ {{#maximum}}
219
+ if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}}
220
+ fail ArgumentError, "invalid value for '{{{name}}}', must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}."
221
+ end
222
+
223
+ {{/maximum}}
224
+ {{#minimum}}
225
+ if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}}
226
+ fail ArgumentError, "invalid value for '{{{name}}}', must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}."
227
+ end
228
+
229
+ {{/minimum}}
230
+ {{#pattern}}
231
+ if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} !~ Regexp.new({{{pattern}}})
232
+ fail ArgumentError, "invalid value for '{{{name}}}', must conform to the pattern {{{pattern}}}."
233
+ end
234
+
235
+ {{/pattern}}
236
+ {{#maxItems}}
237
+ if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.length > {{{maxItems}}}
238
+ fail ArgumentError, "invalid value for '{{{name}}}', number of items must be less than or equal to {{{maxItems}}}."
239
+ end
240
+
241
+ {{/maxItems}}
242
+ {{#minItems}}
243
+ if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.length < {{{minItems}}}
244
+ fail ArgumentError, "invalid value for '{{{name}}}', number of items must be greater than or equal to {{{minItems}}}."
245
+ end
246
+
247
+ {{/minItems}}
248
+ @{{{name}}} = {{{name}}}
249
+ end
250
+
251
+ {{/hasValidation}}
252
+ {{/isEnum}}
253
+ {{/vars}}
254
+ # Checks equality by comparing each attribute.
255
+ # @param [Object] Object to be compared
256
+ def ==(o)
257
+ return true if self.equal?(o)
258
+ self.class == o.class{{#vars}} &&
259
+ {{name}} == o.{{name}}{{/vars}}
260
+ end
261
+
262
+ # @see the `==` method
263
+ # @param [Object] Object to be compared
264
+ def eql?(o)
265
+ self == o
266
+ end
267
+
268
+ # Calculates hash code according to all attributes.
269
+ # @return [Fixnum] Hash code
270
+ def hash
271
+ [{{#vars}}{{name}}{{#hasMore}}, {{/hasMore}}{{/vars}}].hash
272
+ end
273
+
274
+ {{> base_object}}
275
+ end