rcs 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +7 -0
  2. data/lib/environment.rb +7 -0
  3. data/lib/gemconfig.rb +14 -0
  4. data/lib/rcs/company/client.rb +416 -0
  5. data/lib/rcs/company/types/company_register_response.rb +63 -0
  6. data/lib/rcs/company/types/company_register_response_brand.rb +67 -0
  7. data/lib/rcs/company/types/company_update_response.rb +63 -0
  8. data/lib/rcs/company/types/company_update_response_brand.rb +67 -0
  9. data/lib/rcs/send/client.rb +343 -0
  10. data/lib/rcs/send/types/send_mms_response.rb +67 -0
  11. data/lib/rcs/send/types/send_rcs_response.rb +67 -0
  12. data/lib/rcs/send/types/send_sms_response.rb +67 -0
  13. data/lib/rcs/types/action.rb +146 -0
  14. data/lib/rcs/types/action_lat_long.rb +68 -0
  15. data/lib/rcs/types/action_type.rb +16 -0
  16. data/lib/rcs/types/additional_email.rb +65 -0
  17. data/lib/rcs/types/additional_phone_number.rb +65 -0
  18. data/lib/rcs/types/additional_website.rb +65 -0
  19. data/lib/rcs/types/bad_request_error_body.rb +57 -0
  20. data/lib/rcs/types/card.rb +90 -0
  21. data/lib/rcs/types/company.rb +268 -0
  22. data/lib/rcs/types/company_additional_emails_item.rb +67 -0
  23. data/lib/rcs/types/company_additional_phone_numbers_item.rb +67 -0
  24. data/lib/rcs/types/company_additional_websites_item.rb +67 -0
  25. data/lib/rcs/types/company_contact.rb +117 -0
  26. data/lib/rcs/types/company_details.rb +110 -0
  27. data/lib/rcs/types/forbidden_error_body.rb +57 -0
  28. data/lib/rcs/types/internal_server_error_body.rb +57 -0
  29. data/lib/rcs/types/optionals.rb +99 -0
  30. data/lib/rcs/types/point_of_contact.rb +72 -0
  31. data/lib/rcs/types/rcs_functionalities.rb +117 -0
  32. data/lib/rcs/types/unauthorized_error_body.rb +57 -0
  33. data/lib/rcs.rb +126 -0
  34. data/lib/requests.rb +163 -0
  35. data/lib/types_export.rb +29 -0
  36. metadata +158 -0
@@ -0,0 +1,146 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "action_type"
4
+ require_relative "action_lat_long"
5
+ require "ostruct"
6
+ require "json"
7
+
8
+ module Pinnacle
9
+ class Action
10
+ # @return [String] Title of the action (must be less than 25 characters).
11
+ attr_reader :title
12
+ # @return [Pinnacle::ActionType] Type of action for the button. 'openUrl' opens a URL, 'call' dials a phone
13
+ # number, 'trigger' sends the predefined payload to the webhook when pressed,
14
+ # 'requestLocation' requests the user's location, 'scheduleEvent' creates a
15
+ # calendar event, 'sendLocation' sends a location.
16
+ attr_reader :type
17
+ # @return [String] Optional payload associated with the action. This payload encodes the respective
18
+ # fields for the action type and is required. For 'openUrl', the payload is the
19
+ # URL to open. For 'call', the payload is the phone number to dial. For 'trigger',
20
+ # the payload is the predefined payload to send to the webhook.
21
+ attr_reader :payload
22
+ # @return [String] Optional metadata. This is sent alongside the payload to the webhook.
23
+ attr_reader :metadata
24
+ # @return [String] Start time for events. Required for 'scheduleEvent'.
25
+ attr_reader :event_start_time
26
+ # @return [String] End time for events. Required for 'scheduleEvent'.
27
+ attr_reader :event_end_time
28
+ # @return [String] Event title. Required for 'scheduleEvent'.
29
+ attr_reader :event_title
30
+ # @return [String] Optional event description.
31
+ attr_reader :event_description
32
+ # @return [Pinnacle::ActionLatLong] Latitude and longitude coordinates. Required for 'sendLocation'.
33
+ attr_reader :lat_long
34
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
35
+ attr_reader :additional_properties
36
+ # @return [Object]
37
+ attr_reader :_field_set
38
+ protected :_field_set
39
+
40
+ OMIT = Object.new
41
+
42
+ # @param title [String] Title of the action (must be less than 25 characters).
43
+ # @param type [Pinnacle::ActionType] Type of action for the button. 'openUrl' opens a URL, 'call' dials a phone
44
+ # number, 'trigger' sends the predefined payload to the webhook when pressed,
45
+ # 'requestLocation' requests the user's location, 'scheduleEvent' creates a
46
+ # calendar event, 'sendLocation' sends a location.
47
+ # @param payload [String] Optional payload associated with the action. This payload encodes the respective
48
+ # fields for the action type and is required. For 'openUrl', the payload is the
49
+ # URL to open. For 'call', the payload is the phone number to dial. For 'trigger',
50
+ # the payload is the predefined payload to send to the webhook.
51
+ # @param metadata [String] Optional metadata. This is sent alongside the payload to the webhook.
52
+ # @param event_start_time [String] Start time for events. Required for 'scheduleEvent'.
53
+ # @param event_end_time [String] End time for events. Required for 'scheduleEvent'.
54
+ # @param event_title [String] Event title. Required for 'scheduleEvent'.
55
+ # @param event_description [String] Optional event description.
56
+ # @param lat_long [Pinnacle::ActionLatLong] Latitude and longitude coordinates. Required for 'sendLocation'.
57
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
58
+ # @return [Pinnacle::Action]
59
+ def initialize(title: OMIT, type: OMIT, payload: OMIT, metadata: OMIT, event_start_time: OMIT,
60
+ event_end_time: OMIT, event_title: OMIT, event_description: OMIT, lat_long: OMIT, additional_properties: nil)
61
+ @title = title if title != OMIT
62
+ @type = type if type != OMIT
63
+ @payload = payload if payload != OMIT
64
+ @metadata = metadata if metadata != OMIT
65
+ @event_start_time = event_start_time if event_start_time != OMIT
66
+ @event_end_time = event_end_time if event_end_time != OMIT
67
+ @event_title = event_title if event_title != OMIT
68
+ @event_description = event_description if event_description != OMIT
69
+ @lat_long = lat_long if lat_long != OMIT
70
+ @additional_properties = additional_properties
71
+ @_field_set = {
72
+ "title": title,
73
+ "type": type,
74
+ "payload": payload,
75
+ "metadata": metadata,
76
+ "eventStartTime": event_start_time,
77
+ "eventEndTime": event_end_time,
78
+ "eventTitle": event_title,
79
+ "eventDescription": event_description,
80
+ "latLong": lat_long
81
+ }.reject do |_k, v|
82
+ v == OMIT
83
+ end
84
+ end
85
+
86
+ # Deserialize a JSON object to an instance of Action
87
+ #
88
+ # @param json_object [String]
89
+ # @return [Pinnacle::Action]
90
+ def self.from_json(json_object:)
91
+ struct = JSON.parse(json_object, object_class: OpenStruct)
92
+ parsed_json = JSON.parse(json_object)
93
+ title = parsed_json["title"]
94
+ type = parsed_json["type"]
95
+ payload = parsed_json["payload"]
96
+ metadata = parsed_json["metadata"]
97
+ event_start_time = parsed_json["eventStartTime"]
98
+ event_end_time = parsed_json["eventEndTime"]
99
+ event_title = parsed_json["eventTitle"]
100
+ event_description = parsed_json["eventDescription"]
101
+ if parsed_json["latLong"].nil?
102
+ lat_long = nil
103
+ else
104
+ lat_long = parsed_json["latLong"].to_json
105
+ lat_long = Pinnacle::ActionLatLong.from_json(json_object: lat_long)
106
+ end
107
+ new(
108
+ title: title,
109
+ type: type,
110
+ payload: payload,
111
+ metadata: metadata,
112
+ event_start_time: event_start_time,
113
+ event_end_time: event_end_time,
114
+ event_title: event_title,
115
+ event_description: event_description,
116
+ lat_long: lat_long,
117
+ additional_properties: struct
118
+ )
119
+ end
120
+
121
+ # Serialize an instance of Action to a JSON object
122
+ #
123
+ # @return [String]
124
+ def to_json(*_args)
125
+ @_field_set&.to_json
126
+ end
127
+
128
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
129
+ # hash and check each fields type against the current object's property
130
+ # definitions.
131
+ #
132
+ # @param obj [Object]
133
+ # @return [Void]
134
+ def self.validate_raw(obj:)
135
+ obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.")
136
+ obj.type&.is_a?(Pinnacle::ActionType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
137
+ obj.payload&.is_a?(String) != false || raise("Passed value for field obj.payload is not the expected type, validation failed.")
138
+ obj.metadata&.is_a?(String) != false || raise("Passed value for field obj.metadata is not the expected type, validation failed.")
139
+ obj.event_start_time&.is_a?(String) != false || raise("Passed value for field obj.event_start_time is not the expected type, validation failed.")
140
+ obj.event_end_time&.is_a?(String) != false || raise("Passed value for field obj.event_end_time is not the expected type, validation failed.")
141
+ obj.event_title&.is_a?(String) != false || raise("Passed value for field obj.event_title is not the expected type, validation failed.")
142
+ obj.event_description&.is_a?(String) != false || raise("Passed value for field obj.event_description is not the expected type, validation failed.")
143
+ obj.lat_long.nil? || Pinnacle::ActionLatLong.validate_raw(obj: obj.lat_long)
144
+ end
145
+ end
146
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module Pinnacle
7
+ # Latitude and longitude coordinates. Required for 'sendLocation'.
8
+ class ActionLatLong
9
+ # @return [Float] Latitude value.
10
+ attr_reader :lat
11
+ # @return [Float] Longitude value.
12
+ attr_reader :lng
13
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
14
+ attr_reader :additional_properties
15
+ # @return [Object]
16
+ attr_reader :_field_set
17
+ protected :_field_set
18
+
19
+ OMIT = Object.new
20
+
21
+ # @param lat [Float] Latitude value.
22
+ # @param lng [Float] Longitude value.
23
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
24
+ # @return [Pinnacle::ActionLatLong]
25
+ def initialize(lat: OMIT, lng: OMIT, additional_properties: nil)
26
+ @lat = lat if lat != OMIT
27
+ @lng = lng if lng != OMIT
28
+ @additional_properties = additional_properties
29
+ @_field_set = { "lat": lat, "lng": lng }.reject do |_k, v|
30
+ v == OMIT
31
+ end
32
+ end
33
+
34
+ # Deserialize a JSON object to an instance of ActionLatLong
35
+ #
36
+ # @param json_object [String]
37
+ # @return [Pinnacle::ActionLatLong]
38
+ def self.from_json(json_object:)
39
+ struct = JSON.parse(json_object, object_class: OpenStruct)
40
+ parsed_json = JSON.parse(json_object)
41
+ lat = parsed_json["lat"]
42
+ lng = parsed_json["lng"]
43
+ new(
44
+ lat: lat,
45
+ lng: lng,
46
+ additional_properties: struct
47
+ )
48
+ end
49
+
50
+ # Serialize an instance of ActionLatLong to a JSON object
51
+ #
52
+ # @return [String]
53
+ def to_json(*_args)
54
+ @_field_set&.to_json
55
+ end
56
+
57
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
58
+ # hash and check each fields type against the current object's property
59
+ # definitions.
60
+ #
61
+ # @param obj [Object]
62
+ # @return [Void]
63
+ def self.validate_raw(obj:)
64
+ obj.lat&.is_a?(Float) != false || raise("Passed value for field obj.lat is not the expected type, validation failed.")
65
+ obj.lng&.is_a?(Float) != false || raise("Passed value for field obj.lng is not the expected type, validation failed.")
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pinnacle
4
+ # Type of action for the button. 'openUrl' opens a URL, 'call' dials a phone
5
+ # number, 'trigger' sends the predefined payload to the webhook when pressed,
6
+ # 'requestLocation' requests the user's location, 'scheduleEvent' creates a
7
+ # calendar event, 'sendLocation' sends a location.
8
+ class ActionType
9
+ OPEN_URL = "openUrl"
10
+ CALL = "call"
11
+ TRIGGER = "trigger"
12
+ REQUEST_LOCATION = "requestLocation"
13
+ SCHEDULE_EVENT = "scheduleEvent"
14
+ SEND_LOCATION = "sendLocation"
15
+ end
16
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module Pinnacle
7
+ class AdditionalEmail
8
+ # @return [String] Additional email address.
9
+ attr_reader :email
10
+ # @return [String] Label for the additional email address.
11
+ attr_reader :label
12
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
13
+ attr_reader :additional_properties
14
+ # @return [Object]
15
+ attr_reader :_field_set
16
+ protected :_field_set
17
+
18
+ OMIT = Object.new
19
+
20
+ # @param email [String] Additional email address.
21
+ # @param label [String] Label for the additional email address.
22
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
23
+ # @return [Pinnacle::AdditionalEmail]
24
+ def initialize(email:, label:, additional_properties: nil)
25
+ @email = email
26
+ @label = label
27
+ @additional_properties = additional_properties
28
+ @_field_set = { "email": email, "label": label }
29
+ end
30
+
31
+ # Deserialize a JSON object to an instance of AdditionalEmail
32
+ #
33
+ # @param json_object [String]
34
+ # @return [Pinnacle::AdditionalEmail]
35
+ def self.from_json(json_object:)
36
+ struct = JSON.parse(json_object, object_class: OpenStruct)
37
+ parsed_json = JSON.parse(json_object)
38
+ email = parsed_json["email"]
39
+ label = parsed_json["label"]
40
+ new(
41
+ email: email,
42
+ label: label,
43
+ additional_properties: struct
44
+ )
45
+ end
46
+
47
+ # Serialize an instance of AdditionalEmail to a JSON object
48
+ #
49
+ # @return [String]
50
+ def to_json(*_args)
51
+ @_field_set&.to_json
52
+ end
53
+
54
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
55
+ # hash and check each fields type against the current object's property
56
+ # definitions.
57
+ #
58
+ # @param obj [Object]
59
+ # @return [Void]
60
+ def self.validate_raw(obj:)
61
+ obj.email.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.")
62
+ obj.label.is_a?(String) != false || raise("Passed value for field obj.label is not the expected type, validation failed.")
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module Pinnacle
7
+ class AdditionalPhoneNumber
8
+ # @return [String] Additional phone number in international format.
9
+ attr_reader :phone
10
+ # @return [String] Label for the additional phone number.
11
+ attr_reader :label
12
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
13
+ attr_reader :additional_properties
14
+ # @return [Object]
15
+ attr_reader :_field_set
16
+ protected :_field_set
17
+
18
+ OMIT = Object.new
19
+
20
+ # @param phone [String] Additional phone number in international format.
21
+ # @param label [String] Label for the additional phone number.
22
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
23
+ # @return [Pinnacle::AdditionalPhoneNumber]
24
+ def initialize(phone:, label:, additional_properties: nil)
25
+ @phone = phone
26
+ @label = label
27
+ @additional_properties = additional_properties
28
+ @_field_set = { "phone": phone, "label": label }
29
+ end
30
+
31
+ # Deserialize a JSON object to an instance of AdditionalPhoneNumber
32
+ #
33
+ # @param json_object [String]
34
+ # @return [Pinnacle::AdditionalPhoneNumber]
35
+ def self.from_json(json_object:)
36
+ struct = JSON.parse(json_object, object_class: OpenStruct)
37
+ parsed_json = JSON.parse(json_object)
38
+ phone = parsed_json["phone"]
39
+ label = parsed_json["label"]
40
+ new(
41
+ phone: phone,
42
+ label: label,
43
+ additional_properties: struct
44
+ )
45
+ end
46
+
47
+ # Serialize an instance of AdditionalPhoneNumber to a JSON object
48
+ #
49
+ # @return [String]
50
+ def to_json(*_args)
51
+ @_field_set&.to_json
52
+ end
53
+
54
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
55
+ # hash and check each fields type against the current object's property
56
+ # definitions.
57
+ #
58
+ # @param obj [Object]
59
+ # @return [Void]
60
+ def self.validate_raw(obj:)
61
+ obj.phone.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.")
62
+ obj.label.is_a?(String) != false || raise("Passed value for field obj.label is not the expected type, validation failed.")
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module Pinnacle
7
+ class AdditionalWebsite
8
+ # @return [String] URL of the additional website.
9
+ attr_reader :url
10
+ # @return [String] Label for the additional website.
11
+ attr_reader :label
12
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
13
+ attr_reader :additional_properties
14
+ # @return [Object]
15
+ attr_reader :_field_set
16
+ protected :_field_set
17
+
18
+ OMIT = Object.new
19
+
20
+ # @param url [String] URL of the additional website.
21
+ # @param label [String] Label for the additional website.
22
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
23
+ # @return [Pinnacle::AdditionalWebsite]
24
+ def initialize(url:, label:, additional_properties: nil)
25
+ @url = url
26
+ @label = label
27
+ @additional_properties = additional_properties
28
+ @_field_set = { "url": url, "label": label }
29
+ end
30
+
31
+ # Deserialize a JSON object to an instance of AdditionalWebsite
32
+ #
33
+ # @param json_object [String]
34
+ # @return [Pinnacle::AdditionalWebsite]
35
+ def self.from_json(json_object:)
36
+ struct = JSON.parse(json_object, object_class: OpenStruct)
37
+ parsed_json = JSON.parse(json_object)
38
+ url = parsed_json["url"]
39
+ label = parsed_json["label"]
40
+ new(
41
+ url: url,
42
+ label: label,
43
+ additional_properties: struct
44
+ )
45
+ end
46
+
47
+ # Serialize an instance of AdditionalWebsite to a JSON object
48
+ #
49
+ # @return [String]
50
+ def to_json(*_args)
51
+ @_field_set&.to_json
52
+ end
53
+
54
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
55
+ # hash and check each fields type against the current object's property
56
+ # definitions.
57
+ #
58
+ # @param obj [Object]
59
+ # @return [Void]
60
+ def self.validate_raw(obj:)
61
+ obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.")
62
+ obj.label.is_a?(String) != false || raise("Passed value for field obj.label is not the expected type, validation failed.")
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "ostruct"
4
+ require "json"
5
+
6
+ module Pinnacle
7
+ class BadRequestErrorBody
8
+ # @return [Array<String>]
9
+ attr_reader :errors
10
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
11
+ attr_reader :additional_properties
12
+ # @return [Object]
13
+ attr_reader :_field_set
14
+ protected :_field_set
15
+
16
+ OMIT = Object.new
17
+
18
+ # @param errors [Array<String>]
19
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
20
+ # @return [Pinnacle::BadRequestErrorBody]
21
+ def initialize(errors: OMIT, additional_properties: nil)
22
+ @errors = errors if errors != OMIT
23
+ @additional_properties = additional_properties
24
+ @_field_set = { "errors": errors }.reject do |_k, v|
25
+ v == OMIT
26
+ end
27
+ end
28
+
29
+ # Deserialize a JSON object to an instance of BadRequestErrorBody
30
+ #
31
+ # @param json_object [String]
32
+ # @return [Pinnacle::BadRequestErrorBody]
33
+ def self.from_json(json_object:)
34
+ struct = JSON.parse(json_object, object_class: OpenStruct)
35
+ parsed_json = JSON.parse(json_object)
36
+ errors = parsed_json["errors"]
37
+ new(errors: errors, additional_properties: struct)
38
+ end
39
+
40
+ # Serialize an instance of BadRequestErrorBody to a JSON object
41
+ #
42
+ # @return [String]
43
+ def to_json(*_args)
44
+ @_field_set&.to_json
45
+ end
46
+
47
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
48
+ # hash and check each fields type against the current object's property
49
+ # definitions.
50
+ #
51
+ # @param obj [Object]
52
+ # @return [Void]
53
+ def self.validate_raw(obj:)
54
+ obj.errors&.is_a?(Array) != false || raise("Passed value for field obj.errors is not the expected type, validation failed.")
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,90 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "action"
4
+ require "ostruct"
5
+ require "json"
6
+
7
+ module Pinnacle
8
+ class Card
9
+ # @return [String] The title of the card.
10
+ attr_reader :title
11
+ # @return [String] Optional subtitle for the card.
12
+ attr_reader :subtitle
13
+ # @return [String] Optional media URL displayed with the card.
14
+ attr_reader :media_url
15
+ # @return [Array<Pinnacle::Action>] Optional list of buttons on the card (max 4).
16
+ attr_reader :buttons
17
+ # @return [OpenStruct] Additional properties unmapped to the current class definition
18
+ attr_reader :additional_properties
19
+ # @return [Object]
20
+ attr_reader :_field_set
21
+ protected :_field_set
22
+
23
+ OMIT = Object.new
24
+
25
+ # @param title [String] The title of the card.
26
+ # @param subtitle [String] Optional subtitle for the card.
27
+ # @param media_url [String] Optional media URL displayed with the card.
28
+ # @param buttons [Array<Pinnacle::Action>] Optional list of buttons on the card (max 4).
29
+ # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
30
+ # @return [Pinnacle::Card]
31
+ def initialize(title:, subtitle: OMIT, media_url: OMIT, buttons: OMIT, additional_properties: nil)
32
+ @title = title
33
+ @subtitle = subtitle if subtitle != OMIT
34
+ @media_url = media_url if media_url != OMIT
35
+ @buttons = buttons if buttons != OMIT
36
+ @additional_properties = additional_properties
37
+ @_field_set = {
38
+ "title": title,
39
+ "subtitle": subtitle,
40
+ "mediaUrl": media_url,
41
+ "buttons": buttons
42
+ }.reject do |_k, v|
43
+ v == OMIT
44
+ end
45
+ end
46
+
47
+ # Deserialize a JSON object to an instance of Card
48
+ #
49
+ # @param json_object [String]
50
+ # @return [Pinnacle::Card]
51
+ def self.from_json(json_object:)
52
+ struct = JSON.parse(json_object, object_class: OpenStruct)
53
+ parsed_json = JSON.parse(json_object)
54
+ title = parsed_json["title"]
55
+ subtitle = parsed_json["subtitle"]
56
+ media_url = parsed_json["mediaUrl"]
57
+ buttons = parsed_json["buttons"]&.map do |item|
58
+ item = item.to_json
59
+ Pinnacle::Action.from_json(json_object: item)
60
+ end
61
+ new(
62
+ title: title,
63
+ subtitle: subtitle,
64
+ media_url: media_url,
65
+ buttons: buttons,
66
+ additional_properties: struct
67
+ )
68
+ end
69
+
70
+ # Serialize an instance of Card to a JSON object
71
+ #
72
+ # @return [String]
73
+ def to_json(*_args)
74
+ @_field_set&.to_json
75
+ end
76
+
77
+ # Leveraged for Union-type generation, validate_raw attempts to parse the given
78
+ # hash and check each fields type against the current object's property
79
+ # definitions.
80
+ #
81
+ # @param obj [Object]
82
+ # @return [Void]
83
+ def self.validate_raw(obj:)
84
+ obj.title.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.")
85
+ obj.subtitle&.is_a?(String) != false || raise("Passed value for field obj.subtitle is not the expected type, validation failed.")
86
+ obj.media_url&.is_a?(String) != false || raise("Passed value for field obj.media_url is not the expected type, validation failed.")
87
+ obj.buttons&.is_a?(Array) != false || raise("Passed value for field obj.buttons is not the expected type, validation failed.")
88
+ end
89
+ end
90
+ end