affixapi 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/LICENSE +19 -0
  4. data/README.md +374 -0
  5. data/Rakefile +10 -0
  6. data/affixapi.gemspec +38 -0
  7. data/docs/AddressNoNonNullRequest.md +26 -0
  8. data/docs/AddressResponse.md +26 -0
  9. data/docs/Class20230301Api.md +1401 -0
  10. data/docs/ClientRequest.md +24 -0
  11. data/docs/ClientResponse.md +26 -0
  12. data/docs/CompanyResponse.md +28 -0
  13. data/docs/CoreApi.md +69 -0
  14. data/docs/CreateEmployeeRequest.md +68 -0
  15. data/docs/CreateEmployeeRequestBankAccount.md +26 -0
  16. data/docs/CreateEmployeeRequestManager.md +26 -0
  17. data/docs/CurrencyRequest.md +15 -0
  18. data/docs/CurrencyResponse.md +15 -0
  19. data/docs/DeveloperApi.md +777 -0
  20. data/docs/DisconnectResponse.md +18 -0
  21. data/docs/EmployeeResponse.md +74 -0
  22. data/docs/EmploymentNoNullEnumRequest.md +30 -0
  23. data/docs/EmploymentResponse.md +30 -0
  24. data/docs/GroupNoNullEnumRequest.md +24 -0
  25. data/docs/GroupResponse.md +24 -0
  26. data/docs/IdAndMessageResponse.md +20 -0
  27. data/docs/IdentityResponse.md +22 -0
  28. data/docs/InlineResponse400.md +20 -0
  29. data/docs/InlineResponse401.md +22 -0
  30. data/docs/InlineResponse409.md +22 -0
  31. data/docs/IntrospectResponse.md +24 -0
  32. data/docs/LocationNoNonNullRequest.md +26 -0
  33. data/docs/LocationResponse.md +26 -0
  34. data/docs/ManagementApi.md +420 -0
  35. data/docs/MessageResponse.md +18 -0
  36. data/docs/ModeRequest.md +15 -0
  37. data/docs/ModeResponse.md +15 -0
  38. data/docs/OfficialApi.md +631 -0
  39. data/docs/PayrunResponse.md +30 -0
  40. data/docs/PayslipResponse.md +44 -0
  41. data/docs/PayslipResponseContributions.md +20 -0
  42. data/docs/PayslipResponseDeductions.md +20 -0
  43. data/docs/PayslipResponseEarnings.md +22 -0
  44. data/docs/PayslipResponseTaxes.md +22 -0
  45. data/docs/ProviderRequest.md +15 -0
  46. data/docs/ProviderResponse.md +15 -0
  47. data/docs/ScopesRequest.md +15 -0
  48. data/docs/ScopesResponse.md +15 -0
  49. data/docs/TimeOffBalanceResponse.md +32 -0
  50. data/docs/TimeOffEntryResponse.md +40 -0
  51. data/docs/TimesheetResponse.md +32 -0
  52. data/docs/TokenRequest.md +26 -0
  53. data/docs/TokenResponse.md +26 -0
  54. data/git_push.sh +58 -0
  55. data/lib/openapi_client/api/class20230301_api.rb +1198 -0
  56. data/lib/openapi_client/api/core_api.rb +79 -0
  57. data/lib/openapi_client/api/developer_api.rb +677 -0
  58. data/lib/openapi_client/api/management_api.rb +380 -0
  59. data/lib/openapi_client/api/official_api.rb +543 -0
  60. data/lib/openapi_client/api_client.rb +390 -0
  61. data/lib/openapi_client/api_error.rb +57 -0
  62. data/lib/openapi_client/configuration.rb +288 -0
  63. data/lib/openapi_client/models/address_no_non_null_request.rb +295 -0
  64. data/lib/openapi_client/models/address_response.rb +295 -0
  65. data/lib/openapi_client/models/client_request.rb +269 -0
  66. data/lib/openapi_client/models/client_response.rb +284 -0
  67. data/lib/openapi_client/models/company_response.rb +279 -0
  68. data/lib/openapi_client/models/create_employee_request.rb +568 -0
  69. data/lib/openapi_client/models/create_employee_request_bank_account.rb +259 -0
  70. data/lib/openapi_client/models/create_employee_request_manager.rb +263 -0
  71. data/lib/openapi_client/models/currency_request.rb +38 -0
  72. data/lib/openapi_client/models/currency_response.rb +38 -0
  73. data/lib/openapi_client/models/disconnect_response.rb +258 -0
  74. data/lib/openapi_client/models/employee_response.rb +608 -0
  75. data/lib/openapi_client/models/employment_no_null_enum_request.rb +329 -0
  76. data/lib/openapi_client/models/employment_response.rb +329 -0
  77. data/lib/openapi_client/models/group_no_null_enum_request.rb +283 -0
  78. data/lib/openapi_client/models/group_response.rb +283 -0
  79. data/lib/openapi_client/models/id_and_message_response.rb +239 -0
  80. data/lib/openapi_client/models/identity_response.rb +250 -0
  81. data/lib/openapi_client/models/inline_response400.rb +227 -0
  82. data/lib/openapi_client/models/inline_response401.rb +299 -0
  83. data/lib/openapi_client/models/inline_response409.rb +278 -0
  84. data/lib/openapi_client/models/introspect_response.rb +269 -0
  85. data/lib/openapi_client/models/location_no_non_null_request.rb +263 -0
  86. data/lib/openapi_client/models/location_response.rb +263 -0
  87. data/lib/openapi_client/models/message_response.rb +223 -0
  88. data/lib/openapi_client/models/mode_request.rb +37 -0
  89. data/lib/openapi_client/models/mode_response.rb +37 -0
  90. data/lib/openapi_client/models/payrun_response.rb +342 -0
  91. data/lib/openapi_client/models/payslip_response.rb +448 -0
  92. data/lib/openapi_client/models/payslip_response_contributions.rb +238 -0
  93. data/lib/openapi_client/models/payslip_response_deductions.rb +238 -0
  94. data/lib/openapi_client/models/payslip_response_earnings.rb +250 -0
  95. data/lib/openapi_client/models/payslip_response_taxes.rb +248 -0
  96. data/lib/openapi_client/models/provider_request.rb +70 -0
  97. data/lib/openapi_client/models/provider_response.rb +70 -0
  98. data/lib/openapi_client/models/scopes_request.rb +55 -0
  99. data/lib/openapi_client/models/scopes_response.rb +55 -0
  100. data/lib/openapi_client/models/time_off_balance_response.rb +342 -0
  101. data/lib/openapi_client/models/time_off_entry_response.rb +408 -0
  102. data/lib/openapi_client/models/timesheet_response.rb +318 -0
  103. data/lib/openapi_client/models/token_request.rb +318 -0
  104. data/lib/openapi_client/models/token_response.rb +318 -0
  105. data/lib/openapi_client/version.rb +15 -0
  106. data/lib/openapi_client.rb +86 -0
  107. data/openapi_client-0.0.1.gem +0 -0
  108. data/pkg/affixapi-0.0.1.gem +0 -0
  109. data/spec/api/class20230301_api_spec.rb +260 -0
  110. data/spec/api/core_api_spec.rb +46 -0
  111. data/spec/api/developer_api_spec.rb +160 -0
  112. data/spec/api/management_api_spec.rb +103 -0
  113. data/spec/api/official_api_spec.rb +135 -0
  114. data/spec/api_client_spec.rb +226 -0
  115. data/spec/configuration_spec.rb +42 -0
  116. data/spec/models/address_no_non_null_request_spec.rb +62 -0
  117. data/spec/models/address_response_spec.rb +62 -0
  118. data/spec/models/client_request_spec.rb +52 -0
  119. data/spec/models/client_response_spec.rb +58 -0
  120. data/spec/models/company_response_spec.rb +64 -0
  121. data/spec/models/create_employee_request_bank_account_spec.rb +58 -0
  122. data/spec/models/create_employee_request_manager_spec.rb +58 -0
  123. data/spec/models/create_employee_request_spec.rb +204 -0
  124. data/spec/models/currency_request_spec.rb +28 -0
  125. data/spec/models/currency_response_spec.rb +28 -0
  126. data/spec/models/disconnect_response_spec.rb +38 -0
  127. data/spec/models/employee_response_spec.rb +222 -0
  128. data/spec/models/employment_no_null_enum_request_spec.rb +78 -0
  129. data/spec/models/employment_response_spec.rb +78 -0
  130. data/spec/models/group_no_null_enum_request_spec.rb +56 -0
  131. data/spec/models/group_response_spec.rb +56 -0
  132. data/spec/models/id_and_message_response_spec.rb +40 -0
  133. data/spec/models/identity_response_spec.rb +46 -0
  134. data/spec/models/inline_response400_spec.rb +40 -0
  135. data/spec/models/inline_response401_spec.rb +54 -0
  136. data/spec/models/inline_response409_spec.rb +50 -0
  137. data/spec/models/introspect_response_spec.rb +52 -0
  138. data/spec/models/location_no_non_null_request_spec.rb +58 -0
  139. data/spec/models/location_response_spec.rb +58 -0
  140. data/spec/models/message_response_spec.rb +34 -0
  141. data/spec/models/mode_request_spec.rb +28 -0
  142. data/spec/models/mode_response_spec.rb +28 -0
  143. data/spec/models/payrun_response_spec.rb +78 -0
  144. data/spec/models/payslip_response_contributions_spec.rb +40 -0
  145. data/spec/models/payslip_response_deductions_spec.rb +40 -0
  146. data/spec/models/payslip_response_earnings_spec.rb +46 -0
  147. data/spec/models/payslip_response_spec.rb +116 -0
  148. data/spec/models/payslip_response_taxes_spec.rb +46 -0
  149. data/spec/models/provider_request_spec.rb +28 -0
  150. data/spec/models/provider_response_spec.rb +28 -0
  151. data/spec/models/scopes_request_spec.rb +28 -0
  152. data/spec/models/scopes_response_spec.rb +28 -0
  153. data/spec/models/time_off_balance_response_spec.rb +80 -0
  154. data/spec/models/time_off_entry_response_spec.rb +108 -0
  155. data/spec/models/timesheet_response_spec.rb +76 -0
  156. data/spec/models/token_request_spec.rb +62 -0
  157. data/spec/models/token_response_spec.rb +62 -0
  158. data/spec/spec_helper.rb +111 -0
  159. metadata +349 -0
@@ -0,0 +1,448 @@
1
+ =begin
2
+ #Affix API
3
+
4
+ #The affixapi.com API documentation. # Introduction Affix API is an OAuth 2.1 application that allows developers to access customer data, without developers needing to manage or maintain integrations; or collect login credentials or API keys from users for these third party systems. # OAuth 2.1 Affix API follows the [OAuth 2.1 spec](https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-08). As an OAuth application, Affix API handles not only both the collection of sensitive user credentials or API keys, but also builds and maintains the integrations with the providers, so you don't have to. # How to obtain an access token in order to get started, you must: - register a `client_id` - direct your user to the sign in flow (`https://connect.affixapi.com` [with the appropriate query parameters](https://github.com/affixapi/starter-kit/tree/master/connect)) - capture `authorization_code` we will send to your redirect URI after the sign in flow is complete and exchange that `authorization_code` for a Bearer token # Sandbox keys (developer mode) ### dev ``` eyJhbGciOiJFUzI1NiIsImtpZCI6Ims5RmxwSFR1YklmZWNsUU5QRVZzeFcxazFZZ0Zfbk1BWllOSGVuOFQxdGciLCJ0eXAiOiJKV1MifQ.eyJwcm92aWRlciI6InNhbmRib3giLCJzY29wZXMiOlsiLzIwMjMtMDMtMDEvZGV2ZWxvcGVyL2NvbXBhbnkiLCIvMjAyMy0wMy0wMS9kZXZlbG9wZXIvZW1wbG95ZWUiLCIvMjAyMy0wMy0wMS9kZXZlbG9wZXIvZW1wbG95ZWVzIiwiLzIwMjMtMDMtMDEvZGV2ZWxvcGVyL2lkZW50aXR5IiwiLzIwMjMtMDMtMDEvZGV2ZWxvcGVyL3BheXJ1bnMiLCIvMjAyMy0wMy0wMS9kZXZlbG9wZXIvcGF5cnVucy86cGF5cnVuX2lkIiwiLzIwMjM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4MywiaXNzIjoicHVibGljYXBpLWludGVybWVkaWF0ZS5wcm9kLmVuZ2luZWVyaW5nLmFmZml4YXBpLmNvbSIsInN1YiI6ImRldmVsb3BlciIsImF1ZCI6IjA4QkIwODFFLUQ5QUI0RDE0LThERjk5MjMzLTY2NjE1Q0U5In0.2zdpFAmiyYiYk6MOcbXNUwwR4M1Fextnaac340x54AidiWXCyw-u9KeavbqfYF6q8a9kcDLrxhJ8Wc_3tIzuVw' \\ 'https://api.affixapi.com/2023-03-01/developer/employees' ``` # Webhooks An exciting feature for HR/Payroll modes are webhooks. If enabled, your `webhook_uri` is set on your `client_id` for the respective environment: `dev | prod` Webhooks are configured to make live requests to the underlying integration 1x/hr, and if a difference is detected since the last request, we will send a request to your `webhook_uri` with this shape: ``` { added: <api.v20230301.Employees>[ <api.v20230301.Employee>{ ..., date_of_birth: '2010-08-06', display_full_name: 'Daija Rogahn', employee_number: '57993', employment_status: 'pending', employment_type: 'other', employments: [ { currency: 'eur', effective_date: '2022-02-25', employment_type: 'other', job_title: 'Dynamic Implementation Manager', pay_frequency: 'semimonthly', pay_period: 'YEAR', pay_rate: 96000, }, ], first_name: 'Daija', ... } ], removed: [], updated: [ <api.v20230301.Employee>{ ..., date_of_birth: '2009-11-09', display_full_name: 'Lourdes Stiedemann', employee_number: '63189', employment_status: 'leave', employment_type: 'full_time', employments: [ { currency: 'gbp', effective_date: '2023-01-16', employment_type: 'full_time', job_title: 'Forward Brand Planner', pay_frequency: 'semimonthly', pay_period: 'YEAR', pay_rate: 86000, }, ], first_name: 'Lourdes', } ] } ``` the following headers will be sent with webhook requests: ``` x-affix-api-signature: ab8474e609db95d5df3adc39ea3add7a7544bd215c5c520a30a650ae93a2fba7 x-affix-api-origin: webhooks-employees-webhook user-agent: affixapi.com ``` Before trusting the payload, you should sign the payload and verify the signature matches the signature sent by the `affixapi.com` service. This secures that the data sent to your `webhook_uri` is from the `affixapi.com` server. The signature is created by combining the signing secret (your `client_secret`) with the body of the request sent using a standard HMAC-SHA256 keyed hash. The signature can be created via: - create an `HMAC` with your `client_secret` - update the `HMAC` with the payload - get the hex digest -> this is the signature Sample `typescript` code that follows this recipe: ``` import { createHmac } from 'crypto'; export const computeSignature = ({ str, signingSecret, }: { signingSecret: string; str: string; }): string => { const hmac = createHmac('sha256', signingSecret); hmac.update(str); const signature = hmac.digest('hex'); return signature; }; ``` ## Rate limits Open endpoints (not gated by an API key) (applied at endpoint level): - 15 requests every 1 minute (by IP address) - 25 requests every 5 minutes (by IP address) Gated endpoints (require an API key) (applied at endpoint level): - 40 requests every 1 minute (by IP address) - 40 requests every 5 minutes (by `client_id`) Things to keep in mind: - Open endpoints (not gated by an API key) will likely be called by your users, not you, so rate limits generally would not apply to you. - As a developer, rate limits are applied at the endpoint granularity. - For example, say the rate limits below are 10 requests per minute by ip. from that same ip, within 1 minute, you get: - 10 requests per minute on `/orders`, - another 10 requests per minute on `/items`, - and another 10 requests per minute on `/identity`, - for a total of 30 requests per minute.
5
+
6
+ The version of the OpenAPI document: 2023-03-01
7
+ Contact: developers@affixapi.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.1.1
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module OpenapiClient
17
+ class PayslipResponse
18
+ # The Affix-assigned id of the payslip
19
+ attr_accessor :id
20
+
21
+ # the remote system-assigned id of the payrun
22
+ attr_accessor :remote_id
23
+
24
+ attr_accessor :employee_id
25
+
26
+ attr_accessor :payrun_id
27
+
28
+ attr_accessor :currency
29
+
30
+ # if USD/EUR/GBP, in cent
31
+ attr_accessor :gross_pay
32
+
33
+ # if USD/EUR/GBP, in cent
34
+ attr_accessor :net_pay
35
+
36
+ attr_accessor :start_date
37
+
38
+ attr_accessor :end_date
39
+
40
+ attr_accessor :payment_date
41
+
42
+ attr_accessor :earnings
43
+
44
+ # Items paid by the employer that are not included in gross pay, such as employer-paid portion of private health insurance
45
+ attr_accessor :contributions
46
+
47
+ attr_accessor :deductions
48
+
49
+ attr_accessor :taxes
50
+
51
+ class EnumAttributeValidator
52
+ attr_reader :datatype
53
+ attr_reader :allowable_values
54
+
55
+ def initialize(datatype, allowable_values)
56
+ @allowable_values = allowable_values.map do |value|
57
+ case datatype.to_s
58
+ when /Integer/i
59
+ value.to_i
60
+ when /Float/i
61
+ value.to_f
62
+ else
63
+ value
64
+ end
65
+ end
66
+ end
67
+
68
+ def valid?(value)
69
+ !value || allowable_values.include?(value)
70
+ end
71
+ end
72
+
73
+ # Attribute mapping from ruby-style variable name to JSON key.
74
+ def self.attribute_map
75
+ {
76
+ :'id' => :'id',
77
+ :'remote_id' => :'remote_id',
78
+ :'employee_id' => :'employee_id',
79
+ :'payrun_id' => :'payrun_id',
80
+ :'currency' => :'currency',
81
+ :'gross_pay' => :'gross_pay',
82
+ :'net_pay' => :'net_pay',
83
+ :'start_date' => :'start_date',
84
+ :'end_date' => :'end_date',
85
+ :'payment_date' => :'payment_date',
86
+ :'earnings' => :'earnings',
87
+ :'contributions' => :'contributions',
88
+ :'deductions' => :'deductions',
89
+ :'taxes' => :'taxes'
90
+ }
91
+ end
92
+
93
+ # Returns all the JSON keys this model knows about
94
+ def self.acceptable_attributes
95
+ attribute_map.values
96
+ end
97
+
98
+ # Attribute type mapping.
99
+ def self.openapi_types
100
+ {
101
+ :'id' => :'String',
102
+ :'remote_id' => :'String',
103
+ :'employee_id' => :'String',
104
+ :'payrun_id' => :'String',
105
+ :'currency' => :'String',
106
+ :'gross_pay' => :'Float',
107
+ :'net_pay' => :'Float',
108
+ :'start_date' => :'Date',
109
+ :'end_date' => :'Date',
110
+ :'payment_date' => :'Date',
111
+ :'earnings' => :'Array<PayslipResponseEarnings>',
112
+ :'contributions' => :'Array<PayslipResponseContributions>',
113
+ :'deductions' => :'Array<PayslipResponseDeductions>',
114
+ :'taxes' => :'Array<PayslipResponseTaxes>'
115
+ }
116
+ end
117
+
118
+ # List of attributes with nullable: true
119
+ def self.openapi_nullable
120
+ Set.new([
121
+ :'contributions',
122
+ ])
123
+ end
124
+
125
+ # Initializes the object
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ def initialize(attributes = {})
128
+ if (!attributes.is_a?(Hash))
129
+ fail ArgumentError, "The input argument (attributes) must be a hash in `OpenapiClient::PayslipResponse` initialize method"
130
+ end
131
+
132
+ # check to see if the attribute exists and convert string to symbol for hash key
133
+ attributes = attributes.each_with_object({}) { |(k, v), h|
134
+ if (!self.class.attribute_map.key?(k.to_sym))
135
+ fail ArgumentError, "`#{k}` is not a valid attribute in `OpenapiClient::PayslipResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
136
+ end
137
+ h[k.to_sym] = v
138
+ }
139
+
140
+ if attributes.key?(:'id')
141
+ self.id = attributes[:'id']
142
+ end
143
+
144
+ if attributes.key?(:'remote_id')
145
+ self.remote_id = attributes[:'remote_id']
146
+ end
147
+
148
+ if attributes.key?(:'employee_id')
149
+ self.employee_id = attributes[:'employee_id']
150
+ end
151
+
152
+ if attributes.key?(:'payrun_id')
153
+ self.payrun_id = attributes[:'payrun_id']
154
+ end
155
+
156
+ if attributes.key?(:'currency')
157
+ self.currency = attributes[:'currency']
158
+ end
159
+
160
+ if attributes.key?(:'gross_pay')
161
+ self.gross_pay = attributes[:'gross_pay']
162
+ end
163
+
164
+ if attributes.key?(:'net_pay')
165
+ self.net_pay = attributes[:'net_pay']
166
+ end
167
+
168
+ if attributes.key?(:'start_date')
169
+ self.start_date = attributes[:'start_date']
170
+ end
171
+
172
+ if attributes.key?(:'end_date')
173
+ self.end_date = attributes[:'end_date']
174
+ end
175
+
176
+ if attributes.key?(:'payment_date')
177
+ self.payment_date = attributes[:'payment_date']
178
+ end
179
+
180
+ if attributes.key?(:'earnings')
181
+ if (value = attributes[:'earnings']).is_a?(Array)
182
+ self.earnings = value
183
+ end
184
+ end
185
+
186
+ if attributes.key?(:'contributions')
187
+ if (value = attributes[:'contributions']).is_a?(Array)
188
+ self.contributions = value
189
+ end
190
+ end
191
+
192
+ if attributes.key?(:'deductions')
193
+ if (value = attributes[:'deductions']).is_a?(Array)
194
+ self.deductions = value
195
+ end
196
+ end
197
+
198
+ if attributes.key?(:'taxes')
199
+ if (value = attributes[:'taxes']).is_a?(Array)
200
+ self.taxes = value
201
+ end
202
+ end
203
+ end
204
+
205
+ # Show invalid properties with the reasons. Usually used together with valid?
206
+ # @return Array for valid properties with the reasons
207
+ def list_invalid_properties
208
+ invalid_properties = Array.new
209
+ if @id.nil?
210
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
211
+ end
212
+
213
+ if @remote_id.nil?
214
+ invalid_properties.push('invalid value for "remote_id", remote_id cannot be nil.')
215
+ end
216
+
217
+ if @employee_id.nil?
218
+ invalid_properties.push('invalid value for "employee_id", employee_id cannot be nil.')
219
+ end
220
+
221
+ if @payrun_id.nil?
222
+ invalid_properties.push('invalid value for "payrun_id", payrun_id cannot be nil.')
223
+ end
224
+
225
+ if @currency.nil?
226
+ invalid_properties.push('invalid value for "currency", currency cannot be nil.')
227
+ end
228
+
229
+ if @gross_pay.nil?
230
+ invalid_properties.push('invalid value for "gross_pay", gross_pay cannot be nil.')
231
+ end
232
+
233
+ if @net_pay.nil?
234
+ invalid_properties.push('invalid value for "net_pay", net_pay cannot be nil.')
235
+ end
236
+
237
+ if @start_date.nil?
238
+ invalid_properties.push('invalid value for "start_date", start_date cannot be nil.')
239
+ end
240
+
241
+ if @end_date.nil?
242
+ invalid_properties.push('invalid value for "end_date", end_date cannot be nil.')
243
+ end
244
+
245
+ if @payment_date.nil?
246
+ invalid_properties.push('invalid value for "payment_date", payment_date cannot be nil.')
247
+ end
248
+
249
+ if @earnings.nil?
250
+ invalid_properties.push('invalid value for "earnings", earnings cannot be nil.')
251
+ end
252
+
253
+ if @deductions.nil?
254
+ invalid_properties.push('invalid value for "deductions", deductions cannot be nil.')
255
+ end
256
+
257
+ if @taxes.nil?
258
+ invalid_properties.push('invalid value for "taxes", taxes cannot be nil.')
259
+ end
260
+
261
+ invalid_properties
262
+ end
263
+
264
+ # Check to see if the all the properties in the model are valid
265
+ # @return true if the model is valid
266
+ def valid?
267
+ return false if @id.nil?
268
+ return false if @remote_id.nil?
269
+ return false if @employee_id.nil?
270
+ return false if @payrun_id.nil?
271
+ return false if @currency.nil?
272
+ currency_validator = EnumAttributeValidator.new('String', ["usd", "eur", "gbp"])
273
+ return false unless currency_validator.valid?(@currency)
274
+ return false if @gross_pay.nil?
275
+ return false if @net_pay.nil?
276
+ return false if @start_date.nil?
277
+ return false if @end_date.nil?
278
+ return false if @payment_date.nil?
279
+ return false if @earnings.nil?
280
+ return false if @deductions.nil?
281
+ return false if @taxes.nil?
282
+ true
283
+ end
284
+
285
+ # Custom attribute writer method checking allowed values (enum).
286
+ # @param [Object] currency Object to be assigned
287
+ def currency=(currency)
288
+ validator = EnumAttributeValidator.new('String', ["usd", "eur", "gbp"])
289
+ unless validator.valid?(currency)
290
+ fail ArgumentError, "invalid value for \"currency\", must be one of #{validator.allowable_values}."
291
+ end
292
+ @currency = currency
293
+ end
294
+
295
+ # Checks equality by comparing each attribute.
296
+ # @param [Object] Object to be compared
297
+ def ==(o)
298
+ return true if self.equal?(o)
299
+ self.class == o.class &&
300
+ id == o.id &&
301
+ remote_id == o.remote_id &&
302
+ employee_id == o.employee_id &&
303
+ payrun_id == o.payrun_id &&
304
+ currency == o.currency &&
305
+ gross_pay == o.gross_pay &&
306
+ net_pay == o.net_pay &&
307
+ start_date == o.start_date &&
308
+ end_date == o.end_date &&
309
+ payment_date == o.payment_date &&
310
+ earnings == o.earnings &&
311
+ contributions == o.contributions &&
312
+ deductions == o.deductions &&
313
+ taxes == o.taxes
314
+ end
315
+
316
+ # @see the `==` method
317
+ # @param [Object] Object to be compared
318
+ def eql?(o)
319
+ self == o
320
+ end
321
+
322
+ # Calculates hash code according to all attributes.
323
+ # @return [Integer] Hash code
324
+ def hash
325
+ [id, remote_id, employee_id, payrun_id, currency, gross_pay, net_pay, start_date, end_date, payment_date, earnings, contributions, deductions, taxes].hash
326
+ end
327
+
328
+ # Builds the object from hash
329
+ # @param [Hash] attributes Model attributes in the form of hash
330
+ # @return [Object] Returns the model itself
331
+ def self.build_from_hash(attributes)
332
+ new.build_from_hash(attributes)
333
+ end
334
+
335
+ # Builds the object from hash
336
+ # @param [Hash] attributes Model attributes in the form of hash
337
+ # @return [Object] Returns the model itself
338
+ def build_from_hash(attributes)
339
+ return nil unless attributes.is_a?(Hash)
340
+ self.class.openapi_types.each_pair do |key, type|
341
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
342
+ self.send("#{key}=", nil)
343
+ elsif type =~ /\AArray<(.*)>/i
344
+ # check to ensure the input is an array given that the attribute
345
+ # is documented as an array but the input is not
346
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
347
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
348
+ end
349
+ elsif !attributes[self.class.attribute_map[key]].nil?
350
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
351
+ end
352
+ end
353
+
354
+ self
355
+ end
356
+
357
+ # Deserializes the data based on type
358
+ # @param string type Data type
359
+ # @param string value Value to be deserialized
360
+ # @return [Object] Deserialized data
361
+ def _deserialize(type, value)
362
+ case type.to_sym
363
+ when :Time
364
+ Time.parse(value)
365
+ when :Date
366
+ Date.parse(value)
367
+ when :String
368
+ value.to_s
369
+ when :Integer
370
+ value.to_i
371
+ when :Float
372
+ value.to_f
373
+ when :Boolean
374
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
375
+ true
376
+ else
377
+ false
378
+ end
379
+ when :Object
380
+ # generic object (usually a Hash), return directly
381
+ value
382
+ when /\AArray<(?<inner_type>.+)>\z/
383
+ inner_type = Regexp.last_match[:inner_type]
384
+ value.map { |v| _deserialize(inner_type, v) }
385
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
386
+ k_type = Regexp.last_match[:k_type]
387
+ v_type = Regexp.last_match[:v_type]
388
+ {}.tap do |hash|
389
+ value.each do |k, v|
390
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
391
+ end
392
+ end
393
+ else # model
394
+ # models (e.g. Pet) or oneOf
395
+ klass = OpenapiClient.const_get(type)
396
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
397
+ end
398
+ end
399
+
400
+ # Returns the string representation of the object
401
+ # @return [String] String presentation of the object
402
+ def to_s
403
+ to_hash.to_s
404
+ end
405
+
406
+ # to_body is an alias to to_hash (backward compatibility)
407
+ # @return [Hash] Returns the object in the form of hash
408
+ def to_body
409
+ to_hash
410
+ end
411
+
412
+ # Returns the object in the form of hash
413
+ # @return [Hash] Returns the object in the form of hash
414
+ def to_hash
415
+ hash = {}
416
+ self.class.attribute_map.each_pair do |attr, param|
417
+ value = self.send(attr)
418
+ if value.nil?
419
+ is_nullable = self.class.openapi_nullable.include?(attr)
420
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
421
+ end
422
+
423
+ hash[param] = _to_hash(value)
424
+ end
425
+ hash
426
+ end
427
+
428
+ # Outputs non-array value in the form of hash
429
+ # For object, use to_hash. Otherwise, just return the value
430
+ # @param [Object] value Any valid value
431
+ # @return [Hash] Returns the value in the form of hash
432
+ def _to_hash(value)
433
+ if value.is_a?(Array)
434
+ value.compact.map { |v| _to_hash(v) }
435
+ elsif value.is_a?(Hash)
436
+ {}.tap do |hash|
437
+ value.each { |k, v| hash[k] = _to_hash(v) }
438
+ end
439
+ elsif value.respond_to? :to_hash
440
+ value.to_hash
441
+ else
442
+ value
443
+ end
444
+ end
445
+
446
+ end
447
+
448
+ end