icalia-sdk-core 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/lib/icalia-sdk-core.rb +6 -0
  3. data/lib/icalia-sdk-core/version.rb +7 -0
  4. data/lib/icalia/models.rb +34 -0
  5. data/lib/icalia/models/cloud_identity.rb +14 -0
  6. data/lib/icalia/models/code_commit.rb +9 -0
  7. data/lib/icalia/models/code_merge_request.rb +25 -0
  8. data/lib/icalia/models/code_repository.rb +15 -0
  9. data/lib/icalia/models/code_repository_reference.rb +12 -0
  10. data/lib/icalia/models/email_account.rb +10 -0
  11. data/lib/icalia/models/events/authorization_event.rb +9 -0
  12. data/lib/icalia/models/events/code_merge_request_event.rb +13 -0
  13. data/lib/icalia/models/events/code_repository_event.rb +15 -0
  14. data/lib/icalia/models/events/membership_event.rb +11 -0
  15. data/lib/icalia/models/events/organization_event.rb +14 -0
  16. data/lib/icalia/models/membership.rb +9 -0
  17. data/lib/icalia/models/model_base.rb +62 -0
  18. data/lib/icalia/models/model_collection_proxy.rb +13 -0
  19. data/lib/icalia/models/model_proxy.rb +15 -0
  20. data/lib/icalia/models/oauth_access_token.rb +9 -0
  21. data/lib/icalia/models/organization.rb +10 -0
  22. data/lib/icalia/models/person.rb +14 -0
  23. data/lib/icalia/models/resource_action.rb +12 -0
  24. data/lib/icalia/models/resource_identity.rb +15 -0
  25. data/lib/icalia/models/resource_timestamps.rb +11 -0
  26. data/lib/icalia/serialization.rb +76 -0
  27. data/lib/icalia/serialization/deserializable_authorization_event.rb +15 -0
  28. data/lib/icalia/serialization/deserializable_cloud_identity.rb +20 -0
  29. data/lib/icalia/serialization/deserializable_code_check_run.rb +39 -0
  30. data/lib/icalia/serialization/deserializable_code_check_run_event.rb +20 -0
  31. data/lib/icalia/serialization/deserializable_code_check_suite.rb +20 -0
  32. data/lib/icalia/serialization/deserializable_code_commit.rb +16 -0
  33. data/lib/icalia/serialization/deserializable_code_issue.rb +37 -0
  34. data/lib/icalia/serialization/deserializable_code_issue_occurrence.rb +14 -0
  35. data/lib/icalia/serialization/deserializable_code_merge_request.rb +41 -0
  36. data/lib/icalia/serialization/deserializable_code_merge_request_event.rb +17 -0
  37. data/lib/icalia/serialization/deserializable_code_repository.rb +26 -0
  38. data/lib/icalia/serialization/deserializable_code_repository_event.rb +17 -0
  39. data/lib/icalia/serialization/deserializable_code_repository_reference.rb +15 -0
  40. data/lib/icalia/serialization/deserializable_email_account.rb +18 -0
  41. data/lib/icalia/serialization/deserializable_membership.rb +19 -0
  42. data/lib/icalia/serialization/deserializable_membership_event.rb +16 -0
  43. data/lib/icalia/serialization/deserializable_oauth_access_token.rb +31 -0
  44. data/lib/icalia/serialization/deserializable_oauth_application.rb +13 -0
  45. data/lib/icalia/serialization/deserializable_organization.rb +14 -0
  46. data/lib/icalia/serialization/deserializable_organization_event.rb +16 -0
  47. data/lib/icalia/serialization/deserializable_person.rb +26 -0
  48. data/lib/icalia/serialization/deserializable_property_resource.rb +13 -0
  49. data/lib/icalia/serialization/deserializable_resource.rb +39 -0
  50. data/lib/icalia/serialization/deserializable_resource_action.rb +16 -0
  51. data/lib/icalia/serialization/deserializable_resource_creation_timestamp.rb +11 -0
  52. data/lib/icalia/serialization/deserializable_resource_timestamps.rb +12 -0
  53. data/lib/icalia/serialization/deserializable_user.rb +13 -0
  54. data/lib/icalia/serialization/deserializer.rb +108 -0
  55. metadata +171 -0
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ #= DeserializableOauthAccessTokenEvent
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia OAuth Access Token event
8
+ class DeserializableOauthAccessTokenEvent < DeserializableResource
9
+ include DeserializableResourceAction
10
+
11
+ has_one :token do |_rel, id, type|
12
+ Hash[token: get_stand_in(id: id, type: classify_type(type))]
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ #= DeserializableCloudIdentity
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia Event's `User` object
8
+ class DeserializableCloudIdentity < DeserializableResource
9
+ include DeserializableResourceTimestamps
10
+
11
+ attributes :name, :provider
12
+
13
+ attribute(:'identity-type') { |value| Hash[identity_type: value] }
14
+ attribute(:'id-at-provider') { |value| Hash[id_at_provider: value.to_s] }
15
+
16
+ has_one :owner do |_rel, id, type|
17
+ Hash[owner: get_stand_in(id: id, type: classify_type(type))]
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,39 @@
1
+ module Icalia
2
+ #= DeserializableCheckRun
3
+ #
4
+ # This class is responsible for converting a JSONAPI.org representation
5
+ # of an Icalia Event's `CheckRun` object
6
+ class DeserializableCheckRun < DeserializableResource
7
+ include DeserializableResourceTimestamps
8
+
9
+ id { |value| Hash[unique_id: value] }
10
+
11
+ attributes :name
12
+
13
+ attribute(:branch) { |value| Hash[head_branch: value] }
14
+ attribute(:'commit-sha') { |value| Hash[head_sha: value] }
15
+
16
+ attribute :status do |value|
17
+ case value
18
+ when 'started' then Hash[status: 'in_progress']
19
+ when 'finished', 'failed', 'cancelled' then Hash[status: 'completed']
20
+ else Hash[status: 'queued']
21
+ end
22
+ end
23
+
24
+ attributes :conclusion, :output
25
+
26
+ attribute(:'created-at') { |value| Hash[created_at: value] }
27
+ attribute(:'started-at') { |value| Hash[started_at: value] }
28
+ attribute(:'updated-at') { |value| Hash[updated_at: value] }
29
+ attribute(:'completed-at') { |value| Hash[completed_at: value] }
30
+
31
+ has_one :'code-repository' do |_rel, id, _type|
32
+ Hash[tracked_repo_unique_id: id]
33
+ end
34
+
35
+ has_one :'check-suite' do |_rel, id, _type|
36
+ Hash[check_suite_id: CheckSuite.where(unique_id: id).pluck(:id).last]
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,20 @@
1
+ module Icalia
2
+ #= DeserializableCodeCheckRunEvent
3
+ #
4
+ # This class is responsible for converting a JSONAPI.org representation
5
+ # of an Icalia Event's `CodeCheckRunEvent` object
6
+ class DeserializableCodeCheckRunEvent < DeserializableResource
7
+ include DeserializableResourceAction
8
+ include DeserializableResourceCreationTimestamp
9
+
10
+ id { |value| Hash[unique_id: value] }
11
+
12
+ has_one :'check-run' do |_rel, id, type|
13
+ Hash[check_run: id]
14
+ end
15
+
16
+ has_one :'check-suite' do |_rel, id, _type|
17
+ Hash[check_suite_id: CheckSuite.where(unique_id: id).pluck(:id).last]
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ module Icalia
2
+ #= DeserializableCodeCheckRunEvent
3
+ #
4
+ # This class is responsible for converting a JSONAPI.org representation
5
+ # of an Icalia Event's `CodeCheckRunEvent` object
6
+ class DeserializableCodeCheckRunEvent < DeserializableResource
7
+ include DeserializableResourceAction
8
+ include DeserializableResourceCreationTimestamp
9
+
10
+ id { |value| Hash[unique_id: value] }
11
+
12
+ has_one :'check-run' do |_rel, id, type|
13
+ Hash[check_run: id]
14
+ end
15
+
16
+ has_one :'check-suite' do |_rel, id, _type|
17
+ Hash[check_suite_id: CheckSuite.where(unique_id: id).pluck(:id).last]
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ #= DeserializableCodeCommit
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia `CodeCommitReference` object
8
+ class DeserializableCodeCommit < DeserializableResource
9
+ attributes :sha
10
+
11
+ has_one(:repository) do |_rel, id, type|
12
+ stand_in = Icalia::ModelProxy.new id: id, type: classify_type(type)
13
+ Hash[repository: stand_in]
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ #= DeserializableCodeIssue
5
+ #
6
+ # Converts a JSONAPI.org serialization of a `CodeIssue` object from a
7
+ # Notification topic into an `ActionController::Parameters` object that can be
8
+ # used to create or update code issue data
9
+ class DeserializableCodeIssue < DeserializableResource
10
+ LOCATION_DATA_KEYS = %w[path start-line end-line]
11
+
12
+ def self.deserialize_location_data(location_data)
13
+ location_data
14
+ .slice(*LOCATION_DATA_KEYS)
15
+ .transform_keys { |key| key.underscore.to_sym }
16
+ end
17
+
18
+ attribute(:path) { |value| Hash[filename: value] }
19
+
20
+ attribute :location do |value|
21
+ Hash[location: deserialize_location_data(value)]
22
+ end
23
+
24
+ attribute :'other-locations' do |value|
25
+ other_locations_data = (value || [])
26
+ .map { |data| deserialize_location_data data }
27
+
28
+ Hash[other_locations: other_locations_data]
29
+ end
30
+
31
+ attribute(:content) { |value| Hash[content: value] }
32
+ attribute(:description) { |value| Hash[message: value] }
33
+
34
+ attribute(:'check-name') { |value| Hash[check_name: value] }
35
+ attribute(:'engine-name') { |value| Hash[engine_name: value] }
36
+ end
37
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ #= DeserializableCodeIssueOccurrence
5
+ #
6
+ # Converts a JSONAPI.org serialization of a `CodeIssueOcurrence` object
7
+ # notification into an `ActionController::Parameters` object that can be used
8
+ # to create or update repo data
9
+ class DeserializableCodeIssueOccurrence < DeserializableResource
10
+ has_one(:'check-run') { |_rel, id, _type| Hash[check_run_unique_id: id] }
11
+
12
+ has_one(:issue) { |_rel, id, _type| Hash[code_issue_id: id] }
13
+ end
14
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ #= DeserializableCodeMergeRequest
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia Event's `CodeMergeRequestEvent` object that can be used to create or
8
+ # update a code-repository data
9
+ class DeserializableCodeMergeRequest < DeserializableResource
10
+ include DeserializableResourceTimestamps
11
+
12
+ attributes :number, :provider, :body, :state, :title, :url, :additions, :deletions
13
+
14
+ attribute(:'id-at-provider') { |value| Hash[id_at_provider: value] }
15
+ attribute(:'added-line-count') { |value| Hash[added_line_count: value] }
16
+ attribute(:'deleted-line-count') { |value| Hash[deleted_line_count: value] }
17
+ attribute(:'changed-line-count') { |value| Hash[changed_line_count: value] }
18
+
19
+ has_one :author do |_rel, id, type|
20
+ stand_in = Icalia::ModelProxy.new id: id, type: classify_type(type)
21
+ Hash[author: stand_in]
22
+ end
23
+
24
+ has_one :base do |_rel, id, type|
25
+ stand_in = Icalia::ModelProxy.new id: id, type: classify_type(type)
26
+ Hash[base: stand_in]
27
+ end
28
+
29
+ has_one :head do |_rel, id, type|
30
+ stand_in = Icalia::ModelProxy.new id: id, type: classify_type(type)
31
+ Hash[head: stand_in]
32
+ end
33
+
34
+ has_one :committer do |rel, id, type|
35
+ next Hash[committer: nil] unless rel[:data].present?
36
+
37
+ stand_in = Icalia::ModelProxy.new id: id, type: classify_type(type)
38
+ Hash[committer: stand_in]
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ #= DeserializableCodeMergeRequestEvent
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia Event's `CodeMergeRequestEvent` object that can be used to create or
8
+ # update a code-repository data
9
+ class DeserializableCodeMergeRequestEvent < DeserializableResource
10
+ include DeserializableResourceAction
11
+
12
+ has_one :'merge-request' do |_rel, id, type|
13
+ stand_in = Icalia::ModelProxy.new id: id, type: classify_type(type)
14
+ Hash[merge_request: stand_in]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ #= DeserializableCodeRepository
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia Event's `CodeRepository` object
8
+ class DeserializableCodeRepository < DeserializableResource
9
+ include DeserializablePropertyResource # has one owner
10
+ include DeserializableResourceTimestamps
11
+
12
+ attributes :name, :private, :fork, :provider, :description, :url, :fork,
13
+ :exists, :archived
14
+
15
+ attribute(:'html-url') { |value| Hash[html_url: value]}
16
+ attribute(:'full-name') { |value| Hash[full_name: value] }
17
+
18
+ attribute(:'id-at-provider') { |value| Hash[id_at_provider: value] }
19
+ attribute(:'default-branch') { |value| Hash[default_branch: value] }
20
+
21
+ has_one :owner do |_rel, id, type|
22
+ stand_in = Icalia::ModelProxy.new id: id, type: classify_type(type)
23
+ Hash[owner: stand_in]
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ #= DeserializableCodeRepositoryEvent
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia Event's `CodeRepositoryEvent` object that can be used to create or
8
+ # update a code-repository data
9
+ class DeserializableCodeRepositoryEvent < DeserializableResource
10
+ include DeserializableResourceAction
11
+
12
+ has_one :'repository' do |_rel, id, type|
13
+ stand_in = Icalia::ModelProxy.new id: id, type: classify_type(type)
14
+ Hash[repository: stand_in]
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ #= DeserializableCodeRepositoryReference
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia `CodeRepositoryReference` object
8
+ class DeserializableCodeRepositoryReference < DeserializableResource
9
+ attributes :name, :label
10
+
11
+ has_one(:commit) do |_rel, id, type|
12
+ Hash[commit: get_stand_in(id: id, type: classify_type(type))]
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ #= DeserializableEmailAccount
5
+ #
6
+ # Converts a JSONAPI.org serialization of a `EmailAccount` object from a
7
+ # Notification topic into an `ActionController::Parameters` object that can be
8
+ # used to create or update an email account
9
+ class DeserializableEmailAccount < DeserializableResource
10
+ include DeserializableResourceCreationTimestamp
11
+
12
+ attribute :address
13
+
14
+ has_one :owner do |_rel, id, type|
15
+ Hash[owner: get_stand_in(id: id, type: classify_type(type))]
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ #= DeserializableMembership
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia Event's `Membership` object
8
+ class DeserializableMembership < DeserializableResource
9
+ include DeserializableResourceCreationTimestamp
10
+
11
+ has_one :member do |_rel, id, type|
12
+ Hash[member: get_stand_in(id: id, type: classify_type(type))]
13
+ end
14
+
15
+ has_one :group do |_rel, id, type|
16
+ Hash[group: get_stand_in(id: id, type: classify_type(type))]
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ #= DeserializableMembershipEvent
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia Event's `MembershipEvent` object
8
+ class DeserializableMembershipEvent < DeserializableResource
9
+ include DeserializableResourceAction
10
+ include DeserializableResourceCreationTimestamp
11
+
12
+ has_one :membership do |_rel, id, type|
13
+ Hash[membership: get_stand_in(id: id, type: classify_type(type))]
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ #= DeserializableOauthAccessToken
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia OAuth Access Token
8
+ class DeserializableOAuthAccessToken < DeserializableResource
9
+ include DeserializableResourceCreationTimestamp
10
+
11
+ attributes :scopes
12
+
13
+ attribute :'expires-at' do |value|
14
+ parsed_value = !!value ? Time.parse(value) : nil
15
+ Hash[expires_at: parsed_value]
16
+ end
17
+
18
+ attribute :'revoked-at' do |value|
19
+ parsed_value = !!value ? Time.parse(value) : nil
20
+ Hash[revoked_at: parsed_value]
21
+ end
22
+
23
+ has_one :application do |_rel, id, type|
24
+ Hash[application: get_stand_in(id: id, type: classify_type(type))]
25
+ end
26
+
27
+ has_one :'resource-owner' do |_rel, id, type|
28
+ Hash[resource_owner: get_stand_in(id: id, type: classify_type(type))]
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ #= DeserializableOauthApplication
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia OAuth Application
8
+ class DeserializableOauthApplication < DeserializableResource
9
+ include DeserializableResourceTimestamps
10
+
11
+ attributes :name
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Icalia
4
+ #= DeserializableOrganization
5
+ #
6
+ # This class is responsible for converting a JSONAPI.org representation of an
7
+ # Icalia Event's `Organization` object
8
+ class DeserializableOrganization < DeserializableResource
9
+ include DeserializablePropertyResource # has one owner
10
+ include DeserializableResourceTimestamps # created_at and updated_at
11
+
12
+ attributes :name
13
+ end
14
+ end