flat_api 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +7 -0
- data/README.md +248 -0
- data/Rakefile +8 -0
- data/docs/AccountApi.md +55 -0
- data/docs/Assignment.md +18 -0
- data/docs/AssignmentCopy.md +8 -0
- data/docs/AssignmentCreation.md +12 -0
- data/docs/AssignmentSubmission.md +19 -0
- data/docs/AssignmentSubmissionUpdate.md +11 -0
- data/docs/ClassApi.md +1051 -0
- data/docs/ClassAttachmentCreation.md +10 -0
- data/docs/ClassCreation.md +9 -0
- data/docs/ClassDetails.md +25 -0
- data/docs/ClassDetailsCanvas.md +9 -0
- data/docs/ClassDetailsClever.md +14 -0
- data/docs/ClassDetailsGoogleClassroom.md +11 -0
- data/docs/ClassDetailsGoogleDrive.md +9 -0
- data/docs/ClassDetailsLti.md +10 -0
- data/docs/ClassRoles.md +7 -0
- data/docs/ClassState.md +7 -0
- data/docs/ClassUpdate.md +9 -0
- data/docs/FlatErrorResponse.md +11 -0
- data/docs/FlatLocales.md +7 -0
- data/docs/GoogleClassroomCoursework.md +10 -0
- data/docs/GoogleClassroomSubmission.md +10 -0
- data/docs/Group.md +14 -0
- data/docs/GroupApi.md +167 -0
- data/docs/GroupDetails.md +14 -0
- data/docs/GroupType.md +7 -0
- data/docs/LicenseMode.md +7 -0
- data/docs/LicenseSources.md +7 -0
- data/docs/LmsName.md +7 -0
- data/docs/LtiCredentials.md +16 -0
- data/docs/LtiCredentialsCreation.md +9 -0
- data/docs/MediaAttachment.md +23 -0
- data/docs/MediaScoreSharingMode.md +7 -0
- data/docs/OrganizationApi.md +538 -0
- data/docs/OrganizationInvitation.md +14 -0
- data/docs/OrganizationInvitationCreation.md +9 -0
- data/docs/OrganizationRoles.md +7 -0
- data/docs/ScoreApi.md +1605 -0
- data/docs/ScoreCollaborator.md +15 -0
- data/docs/ScoreCollaboratorCreation.md +13 -0
- data/docs/ScoreComment.md +22 -0
- data/docs/ScoreCommentContext.md +14 -0
- data/docs/ScoreCommentCreation.md +13 -0
- data/docs/ScoreCommentUpdate.md +11 -0
- data/docs/ScoreCommentsCounts.md +11 -0
- data/docs/ScoreCreation.md +13 -0
- data/docs/ScoreCreationType.md +7 -0
- data/docs/ScoreData.md +7 -0
- data/docs/ScoreDataEncoding.md +7 -0
- data/docs/ScoreDetails.md +36 -0
- data/docs/ScoreFork.md +7 -0
- data/docs/ScoreLicense.md +7 -0
- data/docs/ScoreLikesCounts.md +10 -0
- data/docs/ScoreModification.md +13 -0
- data/docs/ScorePrivacy.md +7 -0
- data/docs/ScoreRevision.md +14 -0
- data/docs/ScoreRevisionCreation.md +11 -0
- data/docs/ScoreRevisionStatistics.md +9 -0
- data/docs/ScoreRights.md +9 -0
- data/docs/ScoreSource.md +8 -0
- data/docs/ScoreSummary.md +13 -0
- data/docs/ScoreTrack.md +19 -0
- data/docs/ScoreTrackCreation.md +12 -0
- data/docs/ScoreTrackPoint.md +10 -0
- data/docs/ScoreTrackState.md +7 -0
- data/docs/ScoreTrackType.md +7 -0
- data/docs/ScoreTrackUpdate.md +11 -0
- data/docs/ScoreViewsCounts.md +10 -0
- data/docs/UserAdminUpdate.md +9 -0
- data/docs/UserApi.md +173 -0
- data/docs/UserBasics.md +13 -0
- data/docs/UserCreation.md +11 -0
- data/docs/UserDetails.md +28 -0
- data/docs/UserDetailsAdmin.md +20 -0
- data/docs/UserDetailsAdminLicense.md +12 -0
- data/docs/UserInstruments.md +7 -0
- data/docs/UserPublic.md +25 -0
- data/docs/UserPublicSummary.md +17 -0
- data/flat_api.gemspec +48 -0
- data/git_push.sh +55 -0
- data/lib/flat_api.rb +117 -0
- data/lib/flat_api/api/account_api.rb +72 -0
- data/lib/flat_api/api/class_api.rb +1148 -0
- data/lib/flat_api/api/group_api.rb +191 -0
- data/lib/flat_api/api/organization_api.rb +599 -0
- data/lib/flat_api/api/score_api.rb +1737 -0
- data/lib/flat_api/api/user_api.rb +194 -0
- data/lib/flat_api/api_client.rb +389 -0
- data/lib/flat_api/api_error.rb +38 -0
- data/lib/flat_api/configuration.rb +209 -0
- data/lib/flat_api/models/assignment.rb +323 -0
- data/lib/flat_api/models/assignment_copy.rb +194 -0
- data/lib/flat_api/models/assignment_creation.rb +230 -0
- data/lib/flat_api/models/assignment_submission.rb +299 -0
- data/lib/flat_api/models/assignment_submission_update.rb +220 -0
- data/lib/flat_api/models/class_attachment_creation.rb +242 -0
- data/lib/flat_api/models/class_creation.rb +239 -0
- data/lib/flat_api/models/class_details.rb +351 -0
- data/lib/flat_api/models/class_details_canvas.rb +199 -0
- data/lib/flat_api/models/class_details_clever.rb +282 -0
- data/lib/flat_api/models/class_details_google_classroom.rb +219 -0
- data/lib/flat_api/models/class_details_google_drive.rb +199 -0
- data/lib/flat_api/models/class_details_lti.rb +209 -0
- data/lib/flat_api/models/class_roles.rb +22 -0
- data/lib/flat_api/models/class_state.rb +23 -0
- data/lib/flat_api/models/class_update.rb +231 -0
- data/lib/flat_api/models/flat_error_response.rb +219 -0
- data/lib/flat_api/models/flat_locales.rb +27 -0
- data/lib/flat_api/models/google_classroom_coursework.rb +209 -0
- data/lib/flat_api/models/google_classroom_submission.rb +209 -0
- data/lib/flat_api/models/group.rb +282 -0
- data/lib/flat_api/models/group_details.rb +248 -0
- data/lib/flat_api/models/group_type.rb +23 -0
- data/lib/flat_api/models/license_mode.rb +22 -0
- data/lib/flat_api/models/license_sources.rb +25 -0
- data/lib/flat_api/models/lms_name.rb +27 -0
- data/lib/flat_api/models/lti_credentials.rb +268 -0
- data/lib/flat_api/models/lti_credentials_creation.rb +227 -0
- data/lib/flat_api/models/media_attachment.rb +371 -0
- data/lib/flat_api/models/media_score_sharing_mode.rb +23 -0
- data/lib/flat_api/models/organization_invitation.rb +248 -0
- data/lib/flat_api/models/organization_invitation_creation.rb +198 -0
- data/lib/flat_api/models/organization_roles.rb +24 -0
- data/lib/flat_api/models/score_collaborator.rb +263 -0
- data/lib/flat_api/models/score_collaborator_creation.rb +245 -0
- data/lib/flat_api/models/score_comment.rb +363 -0
- data/lib/flat_api/models/score_comment_context.rb +282 -0
- data/lib/flat_api/models/score_comment_creation.rb +245 -0
- data/lib/flat_api/models/score_comment_update.rb +268 -0
- data/lib/flat_api/models/score_comments_counts.rb +219 -0
- data/lib/flat_api/models/score_creation.rb +240 -0
- data/lib/flat_api/models/score_creation_type.rb +23 -0
- data/lib/flat_api/models/score_data.rb +179 -0
- data/lib/flat_api/models/score_data_encoding.rb +21 -0
- data/lib/flat_api/models/score_details.rb +467 -0
- data/lib/flat_api/models/score_fork.rb +179 -0
- data/lib/flat_api/models/score_license.rb +28 -0
- data/lib/flat_api/models/score_likes_counts.rb +209 -0
- data/lib/flat_api/models/score_modification.rb +270 -0
- data/lib/flat_api/models/score_privacy.rb +24 -0
- data/lib/flat_api/models/score_revision.rb +249 -0
- data/lib/flat_api/models/score_revision_creation.rb +222 -0
- data/lib/flat_api/models/score_revision_statistics.rb +199 -0
- data/lib/flat_api/models/score_rights.rb +203 -0
- data/lib/flat_api/models/score_source.rb +189 -0
- data/lib/flat_api/models/score_summary.rb +237 -0
- data/lib/flat_api/models/score_track.rb +298 -0
- data/lib/flat_api/models/score_track_creation.rb +229 -0
- data/lib/flat_api/models/score_track_point.rb +252 -0
- data/lib/flat_api/models/score_track_state.rb +23 -0
- data/lib/flat_api/models/score_track_type.rb +24 -0
- data/lib/flat_api/models/score_track_update.rb +219 -0
- data/lib/flat_api/models/score_views_counts.rb +209 -0
- data/lib/flat_api/models/user_admin_update.rb +214 -0
- data/lib/flat_api/models/user_basics.rb +239 -0
- data/lib/flat_api/models/user_creation.rb +266 -0
- data/lib/flat_api/models/user_details.rb +418 -0
- data/lib/flat_api/models/user_details_admin.rb +306 -0
- data/lib/flat_api/models/user_details_admin_license.rb +227 -0
- data/lib/flat_api/models/user_instruments.rb +179 -0
- data/lib/flat_api/models/user_public.rb +356 -0
- data/lib/flat_api/models/user_public_summary.rb +277 -0
- data/lib/flat_api/version.rb +15 -0
- data/lib/swagger_client.rb +117 -0
- data/lib/swagger_client/api/account_api.rb +72 -0
- data/lib/swagger_client/api/class_api.rb +1148 -0
- data/lib/swagger_client/api/group_api.rb +191 -0
- data/lib/swagger_client/api/organization_api.rb +599 -0
- data/lib/swagger_client/api/score_api.rb +1737 -0
- data/lib/swagger_client/api/user_api.rb +194 -0
- data/lib/swagger_client/api_client.rb +389 -0
- data/lib/swagger_client/api_error.rb +38 -0
- data/lib/swagger_client/configuration.rb +209 -0
- data/lib/swagger_client/models/assignment.rb +323 -0
- data/lib/swagger_client/models/assignment_copy.rb +194 -0
- data/lib/swagger_client/models/assignment_creation.rb +230 -0
- data/lib/swagger_client/models/assignment_submission.rb +299 -0
- data/lib/swagger_client/models/assignment_submission_update.rb +220 -0
- data/lib/swagger_client/models/class_attachment_creation.rb +242 -0
- data/lib/swagger_client/models/class_creation.rb +239 -0
- data/lib/swagger_client/models/class_details.rb +351 -0
- data/lib/swagger_client/models/class_details_canvas.rb +199 -0
- data/lib/swagger_client/models/class_details_clever.rb +282 -0
- data/lib/swagger_client/models/class_details_google_classroom.rb +219 -0
- data/lib/swagger_client/models/class_details_google_drive.rb +199 -0
- data/lib/swagger_client/models/class_details_lti.rb +209 -0
- data/lib/swagger_client/models/class_roles.rb +22 -0
- data/lib/swagger_client/models/class_state.rb +23 -0
- data/lib/swagger_client/models/class_update.rb +231 -0
- data/lib/swagger_client/models/flat_error_response.rb +219 -0
- data/lib/swagger_client/models/flat_locales.rb +27 -0
- data/lib/swagger_client/models/google_classroom_coursework.rb +209 -0
- data/lib/swagger_client/models/google_classroom_submission.rb +209 -0
- data/lib/swagger_client/models/group.rb +282 -0
- data/lib/swagger_client/models/group_details.rb +248 -0
- data/lib/swagger_client/models/group_type.rb +23 -0
- data/lib/swagger_client/models/license_mode.rb +22 -0
- data/lib/swagger_client/models/license_sources.rb +25 -0
- data/lib/swagger_client/models/lms_name.rb +27 -0
- data/lib/swagger_client/models/lti_credentials.rb +268 -0
- data/lib/swagger_client/models/lti_credentials_creation.rb +227 -0
- data/lib/swagger_client/models/media_attachment.rb +371 -0
- data/lib/swagger_client/models/media_score_sharing_mode.rb +23 -0
- data/lib/swagger_client/models/organization_invitation.rb +248 -0
- data/lib/swagger_client/models/organization_invitation_creation.rb +198 -0
- data/lib/swagger_client/models/organization_roles.rb +24 -0
- data/lib/swagger_client/models/score_collaborator.rb +263 -0
- data/lib/swagger_client/models/score_collaborator_creation.rb +245 -0
- data/lib/swagger_client/models/score_comment.rb +363 -0
- data/lib/swagger_client/models/score_comment_context.rb +282 -0
- data/lib/swagger_client/models/score_comment_creation.rb +245 -0
- data/lib/swagger_client/models/score_comment_update.rb +268 -0
- data/lib/swagger_client/models/score_comments_counts.rb +219 -0
- data/lib/swagger_client/models/score_creation.rb +240 -0
- data/lib/swagger_client/models/score_creation_type.rb +23 -0
- data/lib/swagger_client/models/score_data.rb +179 -0
- data/lib/swagger_client/models/score_data_encoding.rb +21 -0
- data/lib/swagger_client/models/score_details.rb +467 -0
- data/lib/swagger_client/models/score_fork.rb +179 -0
- data/lib/swagger_client/models/score_license.rb +28 -0
- data/lib/swagger_client/models/score_likes_counts.rb +209 -0
- data/lib/swagger_client/models/score_modification.rb +270 -0
- data/lib/swagger_client/models/score_privacy.rb +24 -0
- data/lib/swagger_client/models/score_revision.rb +249 -0
- data/lib/swagger_client/models/score_revision_creation.rb +222 -0
- data/lib/swagger_client/models/score_revision_statistics.rb +199 -0
- data/lib/swagger_client/models/score_rights.rb +203 -0
- data/lib/swagger_client/models/score_source.rb +189 -0
- data/lib/swagger_client/models/score_summary.rb +237 -0
- data/lib/swagger_client/models/score_track.rb +298 -0
- data/lib/swagger_client/models/score_track_creation.rb +229 -0
- data/lib/swagger_client/models/score_track_point.rb +252 -0
- data/lib/swagger_client/models/score_track_state.rb +23 -0
- data/lib/swagger_client/models/score_track_type.rb +24 -0
- data/lib/swagger_client/models/score_track_update.rb +219 -0
- data/lib/swagger_client/models/score_views_counts.rb +209 -0
- data/lib/swagger_client/models/user_admin_update.rb +214 -0
- data/lib/swagger_client/models/user_basics.rb +239 -0
- data/lib/swagger_client/models/user_creation.rb +266 -0
- data/lib/swagger_client/models/user_details.rb +418 -0
- data/lib/swagger_client/models/user_details_admin.rb +306 -0
- data/lib/swagger_client/models/user_details_admin_license.rb +227 -0
- data/lib/swagger_client/models/user_instruments.rb +179 -0
- data/lib/swagger_client/models/user_public.rb +356 -0
- data/lib/swagger_client/models/user_public_summary.rb +277 -0
- data/lib/swagger_client/version.rb +15 -0
- data/spec/api/account_api_spec.rb +46 -0
- data/spec/api/class_api_spec.rb +278 -0
- data/spec/api/group_api_spec.rb +72 -0
- data/spec/api/organization_api_spec.rb +162 -0
- data/spec/api/score_api_spec.rb +411 -0
- data/spec/api/user_api_spec.rb +73 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/assignment_copy_spec.rb +42 -0
- data/spec/models/assignment_creation_spec.rb +66 -0
- data/spec/models/assignment_spec.rb +106 -0
- data/spec/models/assignment_submission_spec.rb +108 -0
- data/spec/models/assignment_submission_update_spec.rb +60 -0
- data/spec/models/class_attachment_creation_spec.rb +58 -0
- data/spec/models/class_creation_spec.rb +48 -0
- data/spec/models/class_details_canvas_spec.rb +48 -0
- data/spec/models/class_details_clever_spec.rb +82 -0
- data/spec/models/class_details_google_classroom_spec.rb +60 -0
- data/spec/models/class_details_google_drive_spec.rb +48 -0
- data/spec/models/class_details_lti_spec.rb +54 -0
- data/spec/models/class_details_spec.rb +144 -0
- data/spec/models/class_roles_spec.rb +36 -0
- data/spec/models/class_state_spec.rb +36 -0
- data/spec/models/class_update_spec.rb +48 -0
- data/spec/models/flat_error_response_spec.rb +60 -0
- data/spec/models/flat_locales_spec.rb +36 -0
- data/spec/models/google_classroom_coursework_spec.rb +54 -0
- data/spec/models/google_classroom_submission_spec.rb +54 -0
- data/spec/models/group_details_spec.rb +78 -0
- data/spec/models/group_spec.rb +82 -0
- data/spec/models/group_type_spec.rb +36 -0
- data/spec/models/license_mode_spec.rb +36 -0
- data/spec/models/license_sources_spec.rb +36 -0
- data/spec/models/lms_name_spec.rb +36 -0
- data/spec/models/lti_credentials_creation_spec.rb +48 -0
- data/spec/models/lti_credentials_spec.rb +90 -0
- data/spec/models/media_attachment_spec.rb +136 -0
- data/spec/models/media_score_sharing_mode_spec.rb +36 -0
- data/spec/models/organization_invitation_creation_spec.rb +48 -0
- data/spec/models/organization_invitation_spec.rb +78 -0
- data/spec/models/organization_roles_spec.rb +36 -0
- data/spec/models/score_collaborator_creation_spec.rb +72 -0
- data/spec/models/score_collaborator_spec.rb +84 -0
- data/spec/models/score_comment_context_spec.rb +78 -0
- data/spec/models/score_comment_creation_spec.rb +72 -0
- data/spec/models/score_comment_spec.rb +130 -0
- data/spec/models/score_comment_update_spec.rb +60 -0
- data/spec/models/score_comments_counts_spec.rb +60 -0
- data/spec/models/score_creation_spec.rb +72 -0
- data/spec/models/score_creation_type_spec.rb +36 -0
- data/spec/models/score_data_encoding_spec.rb +36 -0
- data/spec/models/score_data_spec.rb +36 -0
- data/spec/models/score_details_spec.rb +210 -0
- data/spec/models/score_fork_spec.rb +36 -0
- data/spec/models/score_license_spec.rb +36 -0
- data/spec/models/score_likes_counts_spec.rb +54 -0
- data/spec/models/score_modification_spec.rb +72 -0
- data/spec/models/score_privacy_spec.rb +36 -0
- data/spec/models/score_revision_creation_spec.rb +60 -0
- data/spec/models/score_revision_spec.rb +78 -0
- data/spec/models/score_revision_statistics_spec.rb +48 -0
- data/spec/models/score_rights_spec.rb +48 -0
- data/spec/models/score_source_spec.rb +42 -0
- data/spec/models/score_summary_spec.rb +72 -0
- data/spec/models/score_track_creation_spec.rb +66 -0
- data/spec/models/score_track_point_spec.rb +58 -0
- data/spec/models/score_track_spec.rb +108 -0
- data/spec/models/score_track_state_spec.rb +36 -0
- data/spec/models/score_track_type_spec.rb +36 -0
- data/spec/models/score_track_update_spec.rb +60 -0
- data/spec/models/score_views_counts_spec.rb +54 -0
- data/spec/models/user_admin_update_spec.rb +48 -0
- data/spec/models/user_basics_spec.rb +72 -0
- data/spec/models/user_creation_spec.rb +60 -0
- data/spec/models/user_details_admin_license_spec.rb +66 -0
- data/spec/models/user_details_admin_spec.rb +114 -0
- data/spec/models/user_details_spec.rb +166 -0
- data/spec/models/user_instruments_spec.rb +36 -0
- data/spec/models/user_public_spec.rb +144 -0
- data/spec/models/user_public_summary_spec.rb +96 -0
- data/spec/spec_helper.rb +111 -0
- metadata +640 -0
@@ -0,0 +1,266 @@
|
|
1
|
+
=begin
|
2
|
+
#Flat API
|
3
|
+
|
4
|
+
#The Flat API allows you to easily extend the abilities of the [Flat Platform](https://flat.io), with a wide range of use cases including the following: * Creating and importing new music scores using MusicXML or MIDI files * Browsing, updating, copying, exporting the user's scores (for example in MP3, WAV or MIDI) * Managing educational resources with Flat for Education: creating & updating the organization accounts, the classes, rosters and assignments. The Flat API is built on HTTP. Our API is RESTful It has predictable resource URLs. It returns HTTP response codes to indicate errors. It also accepts and returns JSON in the HTTP body. The [schema](/swagger.yaml) of this API follows the [OpenAPI Initiative (OAI) specification](https://www.openapis.org/), you can use and work with [compatible Swagger tools](http://swagger.io/open-source-integrations/). This API features Cross-Origin Resource Sharing (CORS) implemented in compliance with [W3C spec](https://www.w3.org/TR/cors/). You can use your favorite HTTP/REST library for your programming language to use Flat's API. This specification and reference is [available on Github](https://github.com/FlatIO/api-reference). Getting Started and learn more: * [API Overview and interoduction](https://flat.io/developers/docs/api/) * [Authentication (Personal Access Tokens or OAuth2)](https://flat.io/developers/docs/api/authentication.html) * [SDKs](https://flat.io/developers/docs/api/sdks.html) * [Rate Limits](https://flat.io/developers/docs/api/rate-limits.html) * [Changelog](https://flat.io/developers/docs/api/changelog.html)
|
5
|
+
|
6
|
+
OpenAPI spec version: 2.5.1
|
7
|
+
Contact: developers@flat.io
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.2.3-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module FlatApi
|
16
|
+
# User creation
|
17
|
+
class UserCreation
|
18
|
+
# Username of the new account
|
19
|
+
attr_accessor :username
|
20
|
+
|
21
|
+
# Email of the new account
|
22
|
+
attr_accessor :email
|
23
|
+
|
24
|
+
# Password of the new account
|
25
|
+
attr_accessor :password
|
26
|
+
|
27
|
+
attr_accessor :locale
|
28
|
+
|
29
|
+
|
30
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
31
|
+
def self.attribute_map
|
32
|
+
{
|
33
|
+
:'username' => :'username',
|
34
|
+
:'email' => :'email',
|
35
|
+
:'password' => :'password',
|
36
|
+
:'locale' => :'locale'
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
# Attribute type mapping.
|
41
|
+
def self.swagger_types
|
42
|
+
{
|
43
|
+
:'username' => :'String',
|
44
|
+
:'email' => :'String',
|
45
|
+
:'password' => :'String',
|
46
|
+
:'locale' => :'FlatLocales'
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
# Initializes the object
|
51
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
52
|
+
def initialize(attributes = {})
|
53
|
+
return unless attributes.is_a?(Hash)
|
54
|
+
|
55
|
+
# convert string to symbol for hash key
|
56
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
57
|
+
|
58
|
+
if attributes.has_key?(:'username')
|
59
|
+
self.username = attributes[:'username']
|
60
|
+
end
|
61
|
+
|
62
|
+
if attributes.has_key?(:'email')
|
63
|
+
self.email = attributes[:'email']
|
64
|
+
end
|
65
|
+
|
66
|
+
if attributes.has_key?(:'password')
|
67
|
+
self.password = attributes[:'password']
|
68
|
+
end
|
69
|
+
|
70
|
+
if attributes.has_key?(:'locale')
|
71
|
+
self.locale = attributes[:'locale']
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
77
|
+
# @return Array for valid properies with the reasons
|
78
|
+
def list_invalid_properties
|
79
|
+
invalid_properties = Array.new
|
80
|
+
if @username.nil?
|
81
|
+
invalid_properties.push("invalid value for 'username', username cannot be nil.")
|
82
|
+
end
|
83
|
+
|
84
|
+
if @username !~ Regexp.new(/^[A-Za-z0-9\-_.]+$/)
|
85
|
+
invalid_properties.push("invalid value for 'username', must conform to the pattern /^[A-Za-z0-9\-_.]+$/.")
|
86
|
+
end
|
87
|
+
|
88
|
+
if @password.nil?
|
89
|
+
invalid_properties.push("invalid value for 'password', password cannot be nil.")
|
90
|
+
end
|
91
|
+
|
92
|
+
if @password.to_s.length < 6
|
93
|
+
invalid_properties.push("invalid value for 'password', the character length must be great than or equal to 6.")
|
94
|
+
end
|
95
|
+
|
96
|
+
return invalid_properties
|
97
|
+
end
|
98
|
+
|
99
|
+
# Check to see if the all the properties in the model are valid
|
100
|
+
# @return true if the model is valid
|
101
|
+
def valid?
|
102
|
+
return false if @username.nil?
|
103
|
+
return false if @username !~ Regexp.new(/^[A-Za-z0-9\-_.]+$/)
|
104
|
+
return false if @password.nil?
|
105
|
+
return false if @password.to_s.length < 6
|
106
|
+
return true
|
107
|
+
end
|
108
|
+
|
109
|
+
# Custom attribute writer method with validation
|
110
|
+
# @param [Object] username Value to be assigned
|
111
|
+
def username=(username)
|
112
|
+
if username.nil?
|
113
|
+
fail ArgumentError, "username cannot be nil"
|
114
|
+
end
|
115
|
+
|
116
|
+
if username !~ Regexp.new(/^[A-Za-z0-9\-_.]+$/)
|
117
|
+
fail ArgumentError, "invalid value for 'username', must conform to the pattern /^[A-Za-z0-9\-_.]+$/."
|
118
|
+
end
|
119
|
+
|
120
|
+
@username = username
|
121
|
+
end
|
122
|
+
|
123
|
+
# Custom attribute writer method with validation
|
124
|
+
# @param [Object] password Value to be assigned
|
125
|
+
def password=(password)
|
126
|
+
if password.nil?
|
127
|
+
fail ArgumentError, "password cannot be nil"
|
128
|
+
end
|
129
|
+
|
130
|
+
if password.to_s.length < 6
|
131
|
+
fail ArgumentError, "invalid value for 'password', the character length must be great than or equal to 6."
|
132
|
+
end
|
133
|
+
|
134
|
+
@password = password
|
135
|
+
end
|
136
|
+
|
137
|
+
# Checks equality by comparing each attribute.
|
138
|
+
# @param [Object] Object to be compared
|
139
|
+
def ==(o)
|
140
|
+
return true if self.equal?(o)
|
141
|
+
self.class == o.class &&
|
142
|
+
username == o.username &&
|
143
|
+
email == o.email &&
|
144
|
+
password == o.password &&
|
145
|
+
locale == o.locale
|
146
|
+
end
|
147
|
+
|
148
|
+
# @see the `==` method
|
149
|
+
# @param [Object] Object to be compared
|
150
|
+
def eql?(o)
|
151
|
+
self == o
|
152
|
+
end
|
153
|
+
|
154
|
+
# Calculates hash code according to all attributes.
|
155
|
+
# @return [Fixnum] Hash code
|
156
|
+
def hash
|
157
|
+
[username, email, password, locale].hash
|
158
|
+
end
|
159
|
+
|
160
|
+
# Builds the object from hash
|
161
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
162
|
+
# @return [Object] Returns the model itself
|
163
|
+
def build_from_hash(attributes)
|
164
|
+
return nil unless attributes.is_a?(Hash)
|
165
|
+
self.class.swagger_types.each_pair do |key, type|
|
166
|
+
if type =~ /\AArray<(.*)>/i
|
167
|
+
# check to ensure the input is an array given that the the attribute
|
168
|
+
# is documented as an array but the input is not
|
169
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
170
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
171
|
+
end
|
172
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
173
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
174
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
175
|
+
end
|
176
|
+
|
177
|
+
self
|
178
|
+
end
|
179
|
+
|
180
|
+
# Deserializes the data based on type
|
181
|
+
# @param string type Data type
|
182
|
+
# @param string value Value to be deserialized
|
183
|
+
# @return [Object] Deserialized data
|
184
|
+
def _deserialize(type, value)
|
185
|
+
case type.to_sym
|
186
|
+
when :DateTime
|
187
|
+
DateTime.parse(value)
|
188
|
+
when :Date
|
189
|
+
Date.parse(value)
|
190
|
+
when :String
|
191
|
+
value.to_s
|
192
|
+
when :Integer
|
193
|
+
value.to_i
|
194
|
+
when :Float
|
195
|
+
value.to_f
|
196
|
+
when :BOOLEAN
|
197
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
198
|
+
true
|
199
|
+
else
|
200
|
+
false
|
201
|
+
end
|
202
|
+
when :Object
|
203
|
+
# generic object (usually a Hash), return directly
|
204
|
+
value
|
205
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
206
|
+
inner_type = Regexp.last_match[:inner_type]
|
207
|
+
value.map { |v| _deserialize(inner_type, v) }
|
208
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
209
|
+
k_type = Regexp.last_match[:k_type]
|
210
|
+
v_type = Regexp.last_match[:v_type]
|
211
|
+
{}.tap do |hash|
|
212
|
+
value.each do |k, v|
|
213
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
214
|
+
end
|
215
|
+
end
|
216
|
+
else # model
|
217
|
+
temp_model = FlatApi.const_get(type).new
|
218
|
+
temp_model.build_from_hash(value)
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
# Returns the string representation of the object
|
223
|
+
# @return [String] String presentation of the object
|
224
|
+
def to_s
|
225
|
+
to_hash.to_s
|
226
|
+
end
|
227
|
+
|
228
|
+
# to_body is an alias to to_hash (backward compatibility)
|
229
|
+
# @return [Hash] Returns the object in the form of hash
|
230
|
+
def to_body
|
231
|
+
to_hash
|
232
|
+
end
|
233
|
+
|
234
|
+
# Returns the object in the form of hash
|
235
|
+
# @return [Hash] Returns the object in the form of hash
|
236
|
+
def to_hash
|
237
|
+
hash = {}
|
238
|
+
self.class.attribute_map.each_pair do |attr, param|
|
239
|
+
value = self.send(attr)
|
240
|
+
next if value.nil?
|
241
|
+
hash[param] = _to_hash(value)
|
242
|
+
end
|
243
|
+
hash
|
244
|
+
end
|
245
|
+
|
246
|
+
# Outputs non-array value in the form of hash
|
247
|
+
# For object, use to_hash. Otherwise, just return the value
|
248
|
+
# @param [Object] value Any valid value
|
249
|
+
# @return [Hash] Returns the value in the form of hash
|
250
|
+
def _to_hash(value)
|
251
|
+
if value.is_a?(Array)
|
252
|
+
value.compact.map{ |v| _to_hash(v) }
|
253
|
+
elsif value.is_a?(Hash)
|
254
|
+
{}.tap do |hash|
|
255
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
256
|
+
end
|
257
|
+
elsif value.respond_to? :to_hash
|
258
|
+
value.to_hash
|
259
|
+
else
|
260
|
+
value
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
end
|
265
|
+
|
266
|
+
end
|
@@ -0,0 +1,418 @@
|
|
1
|
+
=begin
|
2
|
+
#Flat API
|
3
|
+
|
4
|
+
#The Flat API allows you to easily extend the abilities of the [Flat Platform](https://flat.io), with a wide range of use cases including the following: * Creating and importing new music scores using MusicXML or MIDI files * Browsing, updating, copying, exporting the user's scores (for example in MP3, WAV or MIDI) * Managing educational resources with Flat for Education: creating & updating the organization accounts, the classes, rosters and assignments. The Flat API is built on HTTP. Our API is RESTful It has predictable resource URLs. It returns HTTP response codes to indicate errors. It also accepts and returns JSON in the HTTP body. The [schema](/swagger.yaml) of this API follows the [OpenAPI Initiative (OAI) specification](https://www.openapis.org/), you can use and work with [compatible Swagger tools](http://swagger.io/open-source-integrations/). This API features Cross-Origin Resource Sharing (CORS) implemented in compliance with [W3C spec](https://www.w3.org/TR/cors/). You can use your favorite HTTP/REST library for your programming language to use Flat's API. This specification and reference is [available on Github](https://github.com/FlatIO/api-reference). Getting Started and learn more: * [API Overview and interoduction](https://flat.io/developers/docs/api/) * [Authentication (Personal Access Tokens or OAuth2)](https://flat.io/developers/docs/api/authentication.html) * [SDKs](https://flat.io/developers/docs/api/sdks.html) * [Rate Limits](https://flat.io/developers/docs/api/rate-limits.html) * [Changelog](https://flat.io/developers/docs/api/changelog.html)
|
5
|
+
|
6
|
+
OpenAPI spec version: 2.5.1
|
7
|
+
Contact: developers@flat.io
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
9
|
+
Swagger Codegen version: 2.2.3-SNAPSHOT
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module FlatApi
|
16
|
+
# User details
|
17
|
+
class UserDetails
|
18
|
+
# Identifier of the user
|
19
|
+
attr_accessor :id
|
20
|
+
|
21
|
+
# The user name (unique for the organization)
|
22
|
+
attr_accessor :username
|
23
|
+
|
24
|
+
# A displayable name for the user
|
25
|
+
attr_accessor :name
|
26
|
+
|
27
|
+
# The name that can be directly printed (name or username)
|
28
|
+
attr_accessor :printable_name
|
29
|
+
|
30
|
+
# User pictue
|
31
|
+
attr_accessor :picture
|
32
|
+
|
33
|
+
# User license status. 'True' if user is an individual Power user
|
34
|
+
attr_accessor :is_power_user
|
35
|
+
|
36
|
+
# Organization ID (for Edu users only)
|
37
|
+
attr_accessor :organization
|
38
|
+
|
39
|
+
attr_accessor :organization_role
|
40
|
+
|
41
|
+
attr_accessor :class_role
|
42
|
+
|
43
|
+
# Link to user profile (for Indiv. users only)
|
44
|
+
attr_accessor :html_url
|
45
|
+
|
46
|
+
# User's biography
|
47
|
+
attr_accessor :bio
|
48
|
+
|
49
|
+
# Date the user signed up
|
50
|
+
attr_accessor :registration_date
|
51
|
+
|
52
|
+
# Number of the scores liked by the user
|
53
|
+
attr_accessor :liked_scores_count
|
54
|
+
|
55
|
+
# Number of followers the user have
|
56
|
+
attr_accessor :followers_count
|
57
|
+
|
58
|
+
# Number of people the user follow
|
59
|
+
attr_accessor :following_count
|
60
|
+
|
61
|
+
# Number of public scores the user have
|
62
|
+
attr_accessor :owned_public_scores_count
|
63
|
+
|
64
|
+
# Theme (background) for the profile
|
65
|
+
attr_accessor :profile_theme
|
66
|
+
|
67
|
+
attr_accessor :instruments
|
68
|
+
|
69
|
+
# The type of account
|
70
|
+
attr_accessor :type
|
71
|
+
|
72
|
+
# Tell either this user profile is private or not (individual accounts only)
|
73
|
+
attr_accessor :private_profile
|
74
|
+
|
75
|
+
attr_accessor :locale
|
76
|
+
|
77
|
+
class EnumAttributeValidator
|
78
|
+
attr_reader :datatype
|
79
|
+
attr_reader :allowable_values
|
80
|
+
|
81
|
+
def initialize(datatype, allowable_values)
|
82
|
+
@allowable_values = allowable_values.map do |value|
|
83
|
+
case datatype.to_s
|
84
|
+
when /Integer/i
|
85
|
+
value.to_i
|
86
|
+
when /Float/i
|
87
|
+
value.to_f
|
88
|
+
else
|
89
|
+
value
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def valid?(value)
|
95
|
+
!value || allowable_values.include?(value)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
100
|
+
def self.attribute_map
|
101
|
+
{
|
102
|
+
:'id' => :'id',
|
103
|
+
:'username' => :'username',
|
104
|
+
:'name' => :'name',
|
105
|
+
:'printable_name' => :'printableName',
|
106
|
+
:'picture' => :'picture',
|
107
|
+
:'is_power_user' => :'isPowerUser',
|
108
|
+
:'organization' => :'organization',
|
109
|
+
:'organization_role' => :'organizationRole',
|
110
|
+
:'class_role' => :'classRole',
|
111
|
+
:'html_url' => :'htmlUrl',
|
112
|
+
:'bio' => :'bio',
|
113
|
+
:'registration_date' => :'registrationDate',
|
114
|
+
:'liked_scores_count' => :'likedScoresCount',
|
115
|
+
:'followers_count' => :'followersCount',
|
116
|
+
:'following_count' => :'followingCount',
|
117
|
+
:'owned_public_scores_count' => :'ownedPublicScoresCount',
|
118
|
+
:'profile_theme' => :'profileTheme',
|
119
|
+
:'instruments' => :'instruments',
|
120
|
+
:'type' => :'type',
|
121
|
+
:'private_profile' => :'privateProfile',
|
122
|
+
:'locale' => :'locale'
|
123
|
+
}
|
124
|
+
end
|
125
|
+
|
126
|
+
# Attribute type mapping.
|
127
|
+
def self.swagger_types
|
128
|
+
{
|
129
|
+
:'id' => :'String',
|
130
|
+
:'username' => :'String',
|
131
|
+
:'name' => :'String',
|
132
|
+
:'printable_name' => :'String',
|
133
|
+
:'picture' => :'String',
|
134
|
+
:'is_power_user' => :'BOOLEAN',
|
135
|
+
:'organization' => :'String',
|
136
|
+
:'organization_role' => :'OrganizationRoles',
|
137
|
+
:'class_role' => :'ClassRoles',
|
138
|
+
:'html_url' => :'String',
|
139
|
+
:'bio' => :'String',
|
140
|
+
:'registration_date' => :'DateTime',
|
141
|
+
:'liked_scores_count' => :'Integer',
|
142
|
+
:'followers_count' => :'Integer',
|
143
|
+
:'following_count' => :'Integer',
|
144
|
+
:'owned_public_scores_count' => :'Integer',
|
145
|
+
:'profile_theme' => :'String',
|
146
|
+
:'instruments' => :'UserInstruments',
|
147
|
+
:'type' => :'String',
|
148
|
+
:'private_profile' => :'BOOLEAN',
|
149
|
+
:'locale' => :'FlatLocales'
|
150
|
+
}
|
151
|
+
end
|
152
|
+
|
153
|
+
# Initializes the object
|
154
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
155
|
+
def initialize(attributes = {})
|
156
|
+
return unless attributes.is_a?(Hash)
|
157
|
+
|
158
|
+
# convert string to symbol for hash key
|
159
|
+
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
|
160
|
+
|
161
|
+
if attributes.has_key?(:'id')
|
162
|
+
self.id = attributes[:'id']
|
163
|
+
end
|
164
|
+
|
165
|
+
if attributes.has_key?(:'username')
|
166
|
+
self.username = attributes[:'username']
|
167
|
+
end
|
168
|
+
|
169
|
+
if attributes.has_key?(:'name')
|
170
|
+
self.name = attributes[:'name']
|
171
|
+
end
|
172
|
+
|
173
|
+
if attributes.has_key?(:'printableName')
|
174
|
+
self.printable_name = attributes[:'printableName']
|
175
|
+
end
|
176
|
+
|
177
|
+
if attributes.has_key?(:'picture')
|
178
|
+
self.picture = attributes[:'picture']
|
179
|
+
end
|
180
|
+
|
181
|
+
if attributes.has_key?(:'isPowerUser')
|
182
|
+
self.is_power_user = attributes[:'isPowerUser']
|
183
|
+
end
|
184
|
+
|
185
|
+
if attributes.has_key?(:'organization')
|
186
|
+
self.organization = attributes[:'organization']
|
187
|
+
end
|
188
|
+
|
189
|
+
if attributes.has_key?(:'organizationRole')
|
190
|
+
self.organization_role = attributes[:'organizationRole']
|
191
|
+
end
|
192
|
+
|
193
|
+
if attributes.has_key?(:'classRole')
|
194
|
+
self.class_role = attributes[:'classRole']
|
195
|
+
end
|
196
|
+
|
197
|
+
if attributes.has_key?(:'htmlUrl')
|
198
|
+
self.html_url = attributes[:'htmlUrl']
|
199
|
+
end
|
200
|
+
|
201
|
+
if attributes.has_key?(:'bio')
|
202
|
+
self.bio = attributes[:'bio']
|
203
|
+
end
|
204
|
+
|
205
|
+
if attributes.has_key?(:'registrationDate')
|
206
|
+
self.registration_date = attributes[:'registrationDate']
|
207
|
+
end
|
208
|
+
|
209
|
+
if attributes.has_key?(:'likedScoresCount')
|
210
|
+
self.liked_scores_count = attributes[:'likedScoresCount']
|
211
|
+
end
|
212
|
+
|
213
|
+
if attributes.has_key?(:'followersCount')
|
214
|
+
self.followers_count = attributes[:'followersCount']
|
215
|
+
end
|
216
|
+
|
217
|
+
if attributes.has_key?(:'followingCount')
|
218
|
+
self.following_count = attributes[:'followingCount']
|
219
|
+
end
|
220
|
+
|
221
|
+
if attributes.has_key?(:'ownedPublicScoresCount')
|
222
|
+
self.owned_public_scores_count = attributes[:'ownedPublicScoresCount']
|
223
|
+
end
|
224
|
+
|
225
|
+
if attributes.has_key?(:'profileTheme')
|
226
|
+
self.profile_theme = attributes[:'profileTheme']
|
227
|
+
end
|
228
|
+
|
229
|
+
if attributes.has_key?(:'instruments')
|
230
|
+
self.instruments = attributes[:'instruments']
|
231
|
+
end
|
232
|
+
|
233
|
+
if attributes.has_key?(:'type')
|
234
|
+
self.type = attributes[:'type']
|
235
|
+
end
|
236
|
+
|
237
|
+
if attributes.has_key?(:'privateProfile')
|
238
|
+
self.private_profile = attributes[:'privateProfile']
|
239
|
+
end
|
240
|
+
|
241
|
+
if attributes.has_key?(:'locale')
|
242
|
+
self.locale = attributes[:'locale']
|
243
|
+
end
|
244
|
+
|
245
|
+
end
|
246
|
+
|
247
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
248
|
+
# @return Array for valid properies with the reasons
|
249
|
+
def list_invalid_properties
|
250
|
+
invalid_properties = Array.new
|
251
|
+
return invalid_properties
|
252
|
+
end
|
253
|
+
|
254
|
+
# Check to see if the all the properties in the model are valid
|
255
|
+
# @return true if the model is valid
|
256
|
+
def valid?
|
257
|
+
type_validator = EnumAttributeValidator.new('String', ["user", "guest"])
|
258
|
+
return false unless type_validator.valid?(@type)
|
259
|
+
return true
|
260
|
+
end
|
261
|
+
|
262
|
+
# Custom attribute writer method checking allowed values (enum).
|
263
|
+
# @param [Object] type Object to be assigned
|
264
|
+
def type=(type)
|
265
|
+
validator = EnumAttributeValidator.new('String', ["user", "guest"])
|
266
|
+
unless validator.valid?(type)
|
267
|
+
fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}."
|
268
|
+
end
|
269
|
+
@type = type
|
270
|
+
end
|
271
|
+
|
272
|
+
# Checks equality by comparing each attribute.
|
273
|
+
# @param [Object] Object to be compared
|
274
|
+
def ==(o)
|
275
|
+
return true if self.equal?(o)
|
276
|
+
self.class == o.class &&
|
277
|
+
id == o.id &&
|
278
|
+
username == o.username &&
|
279
|
+
name == o.name &&
|
280
|
+
printable_name == o.printable_name &&
|
281
|
+
picture == o.picture &&
|
282
|
+
is_power_user == o.is_power_user &&
|
283
|
+
organization == o.organization &&
|
284
|
+
organization_role == o.organization_role &&
|
285
|
+
class_role == o.class_role &&
|
286
|
+
html_url == o.html_url &&
|
287
|
+
bio == o.bio &&
|
288
|
+
registration_date == o.registration_date &&
|
289
|
+
liked_scores_count == o.liked_scores_count &&
|
290
|
+
followers_count == o.followers_count &&
|
291
|
+
following_count == o.following_count &&
|
292
|
+
owned_public_scores_count == o.owned_public_scores_count &&
|
293
|
+
profile_theme == o.profile_theme &&
|
294
|
+
instruments == o.instruments &&
|
295
|
+
type == o.type &&
|
296
|
+
private_profile == o.private_profile &&
|
297
|
+
locale == o.locale
|
298
|
+
end
|
299
|
+
|
300
|
+
# @see the `==` method
|
301
|
+
# @param [Object] Object to be compared
|
302
|
+
def eql?(o)
|
303
|
+
self == o
|
304
|
+
end
|
305
|
+
|
306
|
+
# Calculates hash code according to all attributes.
|
307
|
+
# @return [Fixnum] Hash code
|
308
|
+
def hash
|
309
|
+
[id, username, name, printable_name, picture, is_power_user, organization, organization_role, class_role, html_url, bio, registration_date, liked_scores_count, followers_count, following_count, owned_public_scores_count, profile_theme, instruments, type, private_profile, locale].hash
|
310
|
+
end
|
311
|
+
|
312
|
+
# Builds the object from hash
|
313
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
314
|
+
# @return [Object] Returns the model itself
|
315
|
+
def build_from_hash(attributes)
|
316
|
+
return nil unless attributes.is_a?(Hash)
|
317
|
+
self.class.swagger_types.each_pair do |key, type|
|
318
|
+
if type =~ /\AArray<(.*)>/i
|
319
|
+
# check to ensure the input is an array given that the the attribute
|
320
|
+
# is documented as an array but the input is not
|
321
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
322
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
|
323
|
+
end
|
324
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
325
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
326
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
327
|
+
end
|
328
|
+
|
329
|
+
self
|
330
|
+
end
|
331
|
+
|
332
|
+
# Deserializes the data based on type
|
333
|
+
# @param string type Data type
|
334
|
+
# @param string value Value to be deserialized
|
335
|
+
# @return [Object] Deserialized data
|
336
|
+
def _deserialize(type, value)
|
337
|
+
case type.to_sym
|
338
|
+
when :DateTime
|
339
|
+
DateTime.parse(value)
|
340
|
+
when :Date
|
341
|
+
Date.parse(value)
|
342
|
+
when :String
|
343
|
+
value.to_s
|
344
|
+
when :Integer
|
345
|
+
value.to_i
|
346
|
+
when :Float
|
347
|
+
value.to_f
|
348
|
+
when :BOOLEAN
|
349
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
350
|
+
true
|
351
|
+
else
|
352
|
+
false
|
353
|
+
end
|
354
|
+
when :Object
|
355
|
+
# generic object (usually a Hash), return directly
|
356
|
+
value
|
357
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
358
|
+
inner_type = Regexp.last_match[:inner_type]
|
359
|
+
value.map { |v| _deserialize(inner_type, v) }
|
360
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
361
|
+
k_type = Regexp.last_match[:k_type]
|
362
|
+
v_type = Regexp.last_match[:v_type]
|
363
|
+
{}.tap do |hash|
|
364
|
+
value.each do |k, v|
|
365
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
366
|
+
end
|
367
|
+
end
|
368
|
+
else # model
|
369
|
+
temp_model = FlatApi.const_get(type).new
|
370
|
+
temp_model.build_from_hash(value)
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
# Returns the string representation of the object
|
375
|
+
# @return [String] String presentation of the object
|
376
|
+
def to_s
|
377
|
+
to_hash.to_s
|
378
|
+
end
|
379
|
+
|
380
|
+
# to_body is an alias to to_hash (backward compatibility)
|
381
|
+
# @return [Hash] Returns the object in the form of hash
|
382
|
+
def to_body
|
383
|
+
to_hash
|
384
|
+
end
|
385
|
+
|
386
|
+
# Returns the object in the form of hash
|
387
|
+
# @return [Hash] Returns the object in the form of hash
|
388
|
+
def to_hash
|
389
|
+
hash = {}
|
390
|
+
self.class.attribute_map.each_pair do |attr, param|
|
391
|
+
value = self.send(attr)
|
392
|
+
next if value.nil?
|
393
|
+
hash[param] = _to_hash(value)
|
394
|
+
end
|
395
|
+
hash
|
396
|
+
end
|
397
|
+
|
398
|
+
# Outputs non-array value in the form of hash
|
399
|
+
# For object, use to_hash. Otherwise, just return the value
|
400
|
+
# @param [Object] value Any valid value
|
401
|
+
# @return [Hash] Returns the value in the form of hash
|
402
|
+
def _to_hash(value)
|
403
|
+
if value.is_a?(Array)
|
404
|
+
value.compact.map{ |v| _to_hash(v) }
|
405
|
+
elsif value.is_a?(Hash)
|
406
|
+
{}.tap do |hash|
|
407
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
408
|
+
end
|
409
|
+
elsif value.respond_to? :to_hash
|
410
|
+
value.to_hash
|
411
|
+
else
|
412
|
+
value
|
413
|
+
end
|
414
|
+
end
|
415
|
+
|
416
|
+
end
|
417
|
+
|
418
|
+
end
|