rcs 1.0.14 → 1.0.15
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.
- checksums.yaml +4 -4
- data/lib/rcs/company/client.rb +61 -6
- data/lib/rcs/types/company.rb +53 -2
- data/lib/rcs/types/company_category.rb +20 -0
- data/lib/rcs/types/company_details.rb +11 -1
- data/lib/rcs/types/inbound_action_message.rb +117 -0
- data/lib/rcs/types/inbound_location_message.rb +106 -0
- data/lib/rcs/types/inbound_location_message_coordinates.rb +65 -0
- data/lib/rcs/types/inbound_media_message.rb +112 -0
- data/lib/rcs/types/inbound_message.rb +88 -0
- data/lib/rcs/types/inbound_message_message_type.rb +10 -0
- data/lib/rcs/types/inbound_message_metadata.rb +79 -0
- data/lib/rcs/types/inbound_text_message.rb +100 -0
- data/lib/rcs/types/media_payload.rb +65 -0
- data/lib/rcs/types/message_metadata.rb +56 -0
- data/lib/rcs/types/messaging.rb +95 -0
- data/lib/rcs/types/sender_metadata.rb +74 -0
- data/lib/requests.rb +2 -2
- data/lib/types_export.rb +13 -0
- metadata +15 -2
@@ -0,0 +1,106 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "inbound_location_message_coordinates"
|
4
|
+
require_relative "inbound_message_metadata"
|
5
|
+
require "ostruct"
|
6
|
+
require "json"
|
7
|
+
|
8
|
+
module Pinnacle
|
9
|
+
class InboundLocationMessage
|
10
|
+
# @return [String]
|
11
|
+
attr_reader :message_type
|
12
|
+
# @return [Pinnacle::InboundLocationMessageCoordinates]
|
13
|
+
attr_reader :coordinates
|
14
|
+
# @return [String]
|
15
|
+
attr_reader :from
|
16
|
+
# @return [String]
|
17
|
+
attr_reader :to
|
18
|
+
# @return [Pinnacle::InboundMessageMetadata]
|
19
|
+
attr_reader :metadata
|
20
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
21
|
+
attr_reader :additional_properties
|
22
|
+
# @return [Object]
|
23
|
+
attr_reader :_field_set
|
24
|
+
protected :_field_set
|
25
|
+
|
26
|
+
OMIT = Object.new
|
27
|
+
|
28
|
+
# @param message_type [String]
|
29
|
+
# @param coordinates [Pinnacle::InboundLocationMessageCoordinates]
|
30
|
+
# @param from [String]
|
31
|
+
# @param to [String]
|
32
|
+
# @param metadata [Pinnacle::InboundMessageMetadata]
|
33
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
34
|
+
# @return [Pinnacle::InboundLocationMessage]
|
35
|
+
def initialize(coordinates:, from:, to:, message_type: OMIT, metadata: OMIT, additional_properties: nil)
|
36
|
+
@message_type = message_type if message_type != OMIT
|
37
|
+
@coordinates = coordinates
|
38
|
+
@from = from
|
39
|
+
@to = to
|
40
|
+
@metadata = metadata if metadata != OMIT
|
41
|
+
@additional_properties = additional_properties
|
42
|
+
@_field_set = {
|
43
|
+
"messageType": message_type,
|
44
|
+
"coordinates": coordinates,
|
45
|
+
"from": from,
|
46
|
+
"to": to,
|
47
|
+
"metadata": metadata
|
48
|
+
}.reject do |_k, v|
|
49
|
+
v == OMIT
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Deserialize a JSON object to an instance of InboundLocationMessage
|
54
|
+
#
|
55
|
+
# @param json_object [String]
|
56
|
+
# @return [Pinnacle::InboundLocationMessage]
|
57
|
+
def self.from_json(json_object:)
|
58
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
59
|
+
parsed_json = JSON.parse(json_object)
|
60
|
+
message_type = parsed_json["messageType"]
|
61
|
+
if parsed_json["coordinates"].nil?
|
62
|
+
coordinates = nil
|
63
|
+
else
|
64
|
+
coordinates = parsed_json["coordinates"].to_json
|
65
|
+
coordinates = Pinnacle::InboundLocationMessageCoordinates.from_json(json_object: coordinates)
|
66
|
+
end
|
67
|
+
from = parsed_json["from"]
|
68
|
+
to = parsed_json["to"]
|
69
|
+
if parsed_json["metadata"].nil?
|
70
|
+
metadata = nil
|
71
|
+
else
|
72
|
+
metadata = parsed_json["metadata"].to_json
|
73
|
+
metadata = Pinnacle::InboundMessageMetadata.from_json(json_object: metadata)
|
74
|
+
end
|
75
|
+
new(
|
76
|
+
message_type: message_type,
|
77
|
+
coordinates: coordinates,
|
78
|
+
from: from,
|
79
|
+
to: to,
|
80
|
+
metadata: metadata,
|
81
|
+
additional_properties: struct
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Serialize an instance of InboundLocationMessage to a JSON object
|
86
|
+
#
|
87
|
+
# @return [String]
|
88
|
+
def to_json(*_args)
|
89
|
+
@_field_set&.to_json
|
90
|
+
end
|
91
|
+
|
92
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
93
|
+
# hash and check each fields type against the current object's property
|
94
|
+
# definitions.
|
95
|
+
#
|
96
|
+
# @param obj [Object]
|
97
|
+
# @return [Void]
|
98
|
+
def self.validate_raw(obj:)
|
99
|
+
obj.message_type&.is_a?(String) != false || raise("Passed value for field obj.message_type is not the expected type, validation failed.")
|
100
|
+
Pinnacle::InboundLocationMessageCoordinates.validate_raw(obj: obj.coordinates)
|
101
|
+
obj.from.is_a?(String) != false || raise("Passed value for field obj.from is not the expected type, validation failed.")
|
102
|
+
obj.to.is_a?(String) != false || raise("Passed value for field obj.to is not the expected type, validation failed.")
|
103
|
+
obj.metadata.nil? || Pinnacle::InboundMessageMetadata.validate_raw(obj: obj.metadata)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ostruct"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Pinnacle
|
7
|
+
class InboundLocationMessageCoordinates
|
8
|
+
# @return [Float]
|
9
|
+
attr_reader :lat
|
10
|
+
# @return [Float]
|
11
|
+
attr_reader :lng
|
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 lat [Float]
|
21
|
+
# @param lng [Float]
|
22
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
23
|
+
# @return [Pinnacle::InboundLocationMessageCoordinates]
|
24
|
+
def initialize(lat:, lng:, additional_properties: nil)
|
25
|
+
@lat = lat
|
26
|
+
@lng = lng
|
27
|
+
@additional_properties = additional_properties
|
28
|
+
@_field_set = { "lat": lat, "lng": lng }
|
29
|
+
end
|
30
|
+
|
31
|
+
# Deserialize a JSON object to an instance of InboundLocationMessageCoordinates
|
32
|
+
#
|
33
|
+
# @param json_object [String]
|
34
|
+
# @return [Pinnacle::InboundLocationMessageCoordinates]
|
35
|
+
def self.from_json(json_object:)
|
36
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
37
|
+
parsed_json = JSON.parse(json_object)
|
38
|
+
lat = parsed_json["lat"]
|
39
|
+
lng = parsed_json["lng"]
|
40
|
+
new(
|
41
|
+
lat: lat,
|
42
|
+
lng: lng,
|
43
|
+
additional_properties: struct
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Serialize an instance of InboundLocationMessageCoordinates 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.lat.is_a?(Float) != false || raise("Passed value for field obj.lat is not the expected type, validation failed.")
|
62
|
+
obj.lng.is_a?(Float) != false || raise("Passed value for field obj.lng is not the expected type, validation failed.")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "media_payload"
|
4
|
+
require_relative "inbound_message_metadata"
|
5
|
+
require "ostruct"
|
6
|
+
require "json"
|
7
|
+
|
8
|
+
module Pinnacle
|
9
|
+
class InboundMediaMessage
|
10
|
+
# @return [String]
|
11
|
+
attr_reader :message_type
|
12
|
+
# @return [String]
|
13
|
+
attr_reader :text
|
14
|
+
# @return [Array<Pinnacle::MediaPayload>]
|
15
|
+
attr_reader :media_urls
|
16
|
+
# @return [String]
|
17
|
+
attr_reader :from
|
18
|
+
# @return [String]
|
19
|
+
attr_reader :to
|
20
|
+
# @return [Pinnacle::InboundMessageMetadata]
|
21
|
+
attr_reader :metadata
|
22
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
23
|
+
attr_reader :additional_properties
|
24
|
+
# @return [Object]
|
25
|
+
attr_reader :_field_set
|
26
|
+
protected :_field_set
|
27
|
+
|
28
|
+
OMIT = Object.new
|
29
|
+
|
30
|
+
# @param message_type [String]
|
31
|
+
# @param text [String]
|
32
|
+
# @param media_urls [Array<Pinnacle::MediaPayload>]
|
33
|
+
# @param from [String]
|
34
|
+
# @param to [String]
|
35
|
+
# @param metadata [Pinnacle::InboundMessageMetadata]
|
36
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
37
|
+
# @return [Pinnacle::InboundMediaMessage]
|
38
|
+
def initialize(media_urls:, from:, to:, message_type: OMIT, text: OMIT, metadata: OMIT, additional_properties: nil)
|
39
|
+
@message_type = message_type if message_type != OMIT
|
40
|
+
@text = text if text != OMIT
|
41
|
+
@media_urls = media_urls
|
42
|
+
@from = from
|
43
|
+
@to = to
|
44
|
+
@metadata = metadata if metadata != OMIT
|
45
|
+
@additional_properties = additional_properties
|
46
|
+
@_field_set = {
|
47
|
+
"messageType": message_type,
|
48
|
+
"text": text,
|
49
|
+
"mediaUrls": media_urls,
|
50
|
+
"from": from,
|
51
|
+
"to": to,
|
52
|
+
"metadata": metadata
|
53
|
+
}.reject do |_k, v|
|
54
|
+
v == OMIT
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Deserialize a JSON object to an instance of InboundMediaMessage
|
59
|
+
#
|
60
|
+
# @param json_object [String]
|
61
|
+
# @return [Pinnacle::InboundMediaMessage]
|
62
|
+
def self.from_json(json_object:)
|
63
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
64
|
+
parsed_json = JSON.parse(json_object)
|
65
|
+
message_type = parsed_json["messageType"]
|
66
|
+
text = parsed_json["text"]
|
67
|
+
media_urls = parsed_json["mediaUrls"]&.map do |item|
|
68
|
+
item = item.to_json
|
69
|
+
Pinnacle::MediaPayload.from_json(json_object: item)
|
70
|
+
end
|
71
|
+
from = parsed_json["from"]
|
72
|
+
to = parsed_json["to"]
|
73
|
+
if parsed_json["metadata"].nil?
|
74
|
+
metadata = nil
|
75
|
+
else
|
76
|
+
metadata = parsed_json["metadata"].to_json
|
77
|
+
metadata = Pinnacle::InboundMessageMetadata.from_json(json_object: metadata)
|
78
|
+
end
|
79
|
+
new(
|
80
|
+
message_type: message_type,
|
81
|
+
text: text,
|
82
|
+
media_urls: media_urls,
|
83
|
+
from: from,
|
84
|
+
to: to,
|
85
|
+
metadata: metadata,
|
86
|
+
additional_properties: struct
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Serialize an instance of InboundMediaMessage to a JSON object
|
91
|
+
#
|
92
|
+
# @return [String]
|
93
|
+
def to_json(*_args)
|
94
|
+
@_field_set&.to_json
|
95
|
+
end
|
96
|
+
|
97
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
98
|
+
# hash and check each fields type against the current object's property
|
99
|
+
# definitions.
|
100
|
+
#
|
101
|
+
# @param obj [Object]
|
102
|
+
# @return [Void]
|
103
|
+
def self.validate_raw(obj:)
|
104
|
+
obj.message_type&.is_a?(String) != false || raise("Passed value for field obj.message_type is not the expected type, validation failed.")
|
105
|
+
obj.text&.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
|
106
|
+
obj.media_urls.is_a?(Array) != false || raise("Passed value for field obj.media_urls is not the expected type, validation failed.")
|
107
|
+
obj.from.is_a?(String) != false || raise("Passed value for field obj.from is not the expected type, validation failed.")
|
108
|
+
obj.to.is_a?(String) != false || raise("Passed value for field obj.to is not the expected type, validation failed.")
|
109
|
+
obj.metadata.nil? || Pinnacle::InboundMessageMetadata.validate_raw(obj: obj.metadata)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,88 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "inbound_message_message_type"
|
4
|
+
require_relative "inbound_message_metadata"
|
5
|
+
require "ostruct"
|
6
|
+
require "json"
|
7
|
+
|
8
|
+
module Pinnacle
|
9
|
+
class InboundMessage
|
10
|
+
# @return [String]
|
11
|
+
attr_reader :from
|
12
|
+
# @return [String]
|
13
|
+
attr_reader :to
|
14
|
+
# @return [Pinnacle::InboundMessageMessageType]
|
15
|
+
attr_reader :message_type
|
16
|
+
# @return [Pinnacle::InboundMessageMetadata]
|
17
|
+
attr_reader :metadata
|
18
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
19
|
+
attr_reader :additional_properties
|
20
|
+
# @return [Object]
|
21
|
+
attr_reader :_field_set
|
22
|
+
protected :_field_set
|
23
|
+
|
24
|
+
OMIT = Object.new
|
25
|
+
|
26
|
+
# @param from [String]
|
27
|
+
# @param to [String]
|
28
|
+
# @param message_type [Pinnacle::InboundMessageMessageType]
|
29
|
+
# @param metadata [Pinnacle::InboundMessageMetadata]
|
30
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
31
|
+
# @return [Pinnacle::InboundMessage]
|
32
|
+
def initialize(from:, to:, message_type:, metadata: OMIT, additional_properties: nil)
|
33
|
+
@from = from
|
34
|
+
@to = to
|
35
|
+
@message_type = message_type
|
36
|
+
@metadata = metadata if metadata != OMIT
|
37
|
+
@additional_properties = additional_properties
|
38
|
+
@_field_set = { "from": from, "to": to, "messageType": message_type, "metadata": metadata }.reject do |_k, v|
|
39
|
+
v == OMIT
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Deserialize a JSON object to an instance of InboundMessage
|
44
|
+
#
|
45
|
+
# @param json_object [String]
|
46
|
+
# @return [Pinnacle::InboundMessage]
|
47
|
+
def self.from_json(json_object:)
|
48
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
49
|
+
parsed_json = JSON.parse(json_object)
|
50
|
+
from = parsed_json["from"]
|
51
|
+
to = parsed_json["to"]
|
52
|
+
message_type = parsed_json["messageType"]
|
53
|
+
if parsed_json["metadata"].nil?
|
54
|
+
metadata = nil
|
55
|
+
else
|
56
|
+
metadata = parsed_json["metadata"].to_json
|
57
|
+
metadata = Pinnacle::InboundMessageMetadata.from_json(json_object: metadata)
|
58
|
+
end
|
59
|
+
new(
|
60
|
+
from: from,
|
61
|
+
to: to,
|
62
|
+
message_type: message_type,
|
63
|
+
metadata: metadata,
|
64
|
+
additional_properties: struct
|
65
|
+
)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Serialize an instance of InboundMessage to a JSON object
|
69
|
+
#
|
70
|
+
# @return [String]
|
71
|
+
def to_json(*_args)
|
72
|
+
@_field_set&.to_json
|
73
|
+
end
|
74
|
+
|
75
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
76
|
+
# hash and check each fields type against the current object's property
|
77
|
+
# definitions.
|
78
|
+
#
|
79
|
+
# @param obj [Object]
|
80
|
+
# @return [Void]
|
81
|
+
def self.validate_raw(obj:)
|
82
|
+
obj.from.is_a?(String) != false || raise("Passed value for field obj.from is not the expected type, validation failed.")
|
83
|
+
obj.to.is_a?(String) != false || raise("Passed value for field obj.to is not the expected type, validation failed.")
|
84
|
+
obj.message_type.is_a?(Pinnacle::InboundMessageMessageType) != false || raise("Passed value for field obj.message_type is not the expected type, validation failed.")
|
85
|
+
obj.metadata.nil? || Pinnacle::InboundMessageMetadata.validate_raw(obj: obj.metadata)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "sender_metadata"
|
4
|
+
require_relative "message_metadata"
|
5
|
+
require "ostruct"
|
6
|
+
require "json"
|
7
|
+
|
8
|
+
module Pinnacle
|
9
|
+
class InboundMessageMetadata
|
10
|
+
# @return [Pinnacle::SenderMetadata]
|
11
|
+
attr_reader :sender
|
12
|
+
# @return [Pinnacle::MessageMetadata]
|
13
|
+
attr_reader :message
|
14
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
15
|
+
attr_reader :additional_properties
|
16
|
+
# @return [Object]
|
17
|
+
attr_reader :_field_set
|
18
|
+
protected :_field_set
|
19
|
+
|
20
|
+
OMIT = Object.new
|
21
|
+
|
22
|
+
# @param sender [Pinnacle::SenderMetadata]
|
23
|
+
# @param message [Pinnacle::MessageMetadata]
|
24
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
25
|
+
# @return [Pinnacle::InboundMessageMetadata]
|
26
|
+
def initialize(sender: OMIT, message: OMIT, additional_properties: nil)
|
27
|
+
@sender = sender if sender != OMIT
|
28
|
+
@message = message if message != OMIT
|
29
|
+
@additional_properties = additional_properties
|
30
|
+
@_field_set = { "sender": sender, "message": message }.reject do |_k, v|
|
31
|
+
v == OMIT
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Deserialize a JSON object to an instance of InboundMessageMetadata
|
36
|
+
#
|
37
|
+
# @param json_object [String]
|
38
|
+
# @return [Pinnacle::InboundMessageMetadata]
|
39
|
+
def self.from_json(json_object:)
|
40
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
41
|
+
parsed_json = JSON.parse(json_object)
|
42
|
+
if parsed_json["sender"].nil?
|
43
|
+
sender = nil
|
44
|
+
else
|
45
|
+
sender = parsed_json["sender"].to_json
|
46
|
+
sender = Pinnacle::SenderMetadata.from_json(json_object: sender)
|
47
|
+
end
|
48
|
+
if parsed_json["message"].nil?
|
49
|
+
message = nil
|
50
|
+
else
|
51
|
+
message = parsed_json["message"].to_json
|
52
|
+
message = Pinnacle::MessageMetadata.from_json(json_object: message)
|
53
|
+
end
|
54
|
+
new(
|
55
|
+
sender: sender,
|
56
|
+
message: message,
|
57
|
+
additional_properties: struct
|
58
|
+
)
|
59
|
+
end
|
60
|
+
|
61
|
+
# Serialize an instance of InboundMessageMetadata to a JSON object
|
62
|
+
#
|
63
|
+
# @return [String]
|
64
|
+
def to_json(*_args)
|
65
|
+
@_field_set&.to_json
|
66
|
+
end
|
67
|
+
|
68
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
69
|
+
# hash and check each fields type against the current object's property
|
70
|
+
# definitions.
|
71
|
+
#
|
72
|
+
# @param obj [Object]
|
73
|
+
# @return [Void]
|
74
|
+
def self.validate_raw(obj:)
|
75
|
+
obj.sender.nil? || Pinnacle::SenderMetadata.validate_raw(obj: obj.sender)
|
76
|
+
obj.message.nil? || Pinnacle::MessageMetadata.validate_raw(obj: obj.message)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "inbound_message_metadata"
|
4
|
+
require "ostruct"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
module Pinnacle
|
8
|
+
class InboundTextMessage
|
9
|
+
# @return [String]
|
10
|
+
attr_reader :message_type
|
11
|
+
# @return [String]
|
12
|
+
attr_reader :text
|
13
|
+
# @return [String]
|
14
|
+
attr_reader :from
|
15
|
+
# @return [String]
|
16
|
+
attr_reader :to
|
17
|
+
# @return [Pinnacle::InboundMessageMetadata]
|
18
|
+
attr_reader :metadata
|
19
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
20
|
+
attr_reader :additional_properties
|
21
|
+
# @return [Object]
|
22
|
+
attr_reader :_field_set
|
23
|
+
protected :_field_set
|
24
|
+
|
25
|
+
OMIT = Object.new
|
26
|
+
|
27
|
+
# @param message_type [String]
|
28
|
+
# @param text [String]
|
29
|
+
# @param from [String]
|
30
|
+
# @param to [String]
|
31
|
+
# @param metadata [Pinnacle::InboundMessageMetadata]
|
32
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
33
|
+
# @return [Pinnacle::InboundTextMessage]
|
34
|
+
def initialize(text:, from:, to:, message_type: OMIT, metadata: OMIT, additional_properties: nil)
|
35
|
+
@message_type = message_type if message_type != OMIT
|
36
|
+
@text = text
|
37
|
+
@from = from
|
38
|
+
@to = to
|
39
|
+
@metadata = metadata if metadata != OMIT
|
40
|
+
@additional_properties = additional_properties
|
41
|
+
@_field_set = {
|
42
|
+
"messageType": message_type,
|
43
|
+
"text": text,
|
44
|
+
"from": from,
|
45
|
+
"to": to,
|
46
|
+
"metadata": metadata
|
47
|
+
}.reject do |_k, v|
|
48
|
+
v == OMIT
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Deserialize a JSON object to an instance of InboundTextMessage
|
53
|
+
#
|
54
|
+
# @param json_object [String]
|
55
|
+
# @return [Pinnacle::InboundTextMessage]
|
56
|
+
def self.from_json(json_object:)
|
57
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
58
|
+
parsed_json = JSON.parse(json_object)
|
59
|
+
message_type = parsed_json["messageType"]
|
60
|
+
text = parsed_json["text"]
|
61
|
+
from = parsed_json["from"]
|
62
|
+
to = parsed_json["to"]
|
63
|
+
if parsed_json["metadata"].nil?
|
64
|
+
metadata = nil
|
65
|
+
else
|
66
|
+
metadata = parsed_json["metadata"].to_json
|
67
|
+
metadata = Pinnacle::InboundMessageMetadata.from_json(json_object: metadata)
|
68
|
+
end
|
69
|
+
new(
|
70
|
+
message_type: message_type,
|
71
|
+
text: text,
|
72
|
+
from: from,
|
73
|
+
to: to,
|
74
|
+
metadata: metadata,
|
75
|
+
additional_properties: struct
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Serialize an instance of InboundTextMessage to a JSON object
|
80
|
+
#
|
81
|
+
# @return [String]
|
82
|
+
def to_json(*_args)
|
83
|
+
@_field_set&.to_json
|
84
|
+
end
|
85
|
+
|
86
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
87
|
+
# hash and check each fields type against the current object's property
|
88
|
+
# definitions.
|
89
|
+
#
|
90
|
+
# @param obj [Object]
|
91
|
+
# @return [Void]
|
92
|
+
def self.validate_raw(obj:)
|
93
|
+
obj.message_type&.is_a?(String) != false || raise("Passed value for field obj.message_type is not the expected type, validation failed.")
|
94
|
+
obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.")
|
95
|
+
obj.from.is_a?(String) != false || raise("Passed value for field obj.from is not the expected type, validation failed.")
|
96
|
+
obj.to.is_a?(String) != false || raise("Passed value for field obj.to is not the expected type, validation failed.")
|
97
|
+
obj.metadata.nil? || Pinnacle::InboundMessageMetadata.validate_raw(obj: obj.metadata)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "ostruct"
|
4
|
+
require "json"
|
5
|
+
|
6
|
+
module Pinnacle
|
7
|
+
class MediaPayload
|
8
|
+
# @return [String]
|
9
|
+
attr_reader :type
|
10
|
+
# @return [String]
|
11
|
+
attr_reader :url
|
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 type [String]
|
21
|
+
# @param url [String]
|
22
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
23
|
+
# @return [Pinnacle::MediaPayload]
|
24
|
+
def initialize(type:, url:, additional_properties: nil)
|
25
|
+
@type = type
|
26
|
+
@url = url
|
27
|
+
@additional_properties = additional_properties
|
28
|
+
@_field_set = { "type": type, "url": url }
|
29
|
+
end
|
30
|
+
|
31
|
+
# Deserialize a JSON object to an instance of MediaPayload
|
32
|
+
#
|
33
|
+
# @param json_object [String]
|
34
|
+
# @return [Pinnacle::MediaPayload]
|
35
|
+
def self.from_json(json_object:)
|
36
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
37
|
+
parsed_json = JSON.parse(json_object)
|
38
|
+
type = parsed_json["type"]
|
39
|
+
url = parsed_json["url"]
|
40
|
+
new(
|
41
|
+
type: type,
|
42
|
+
url: url,
|
43
|
+
additional_properties: struct
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Serialize an instance of MediaPayload 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.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.")
|
62
|
+
obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "date"
|
4
|
+
require "ostruct"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
module Pinnacle
|
8
|
+
class MessageMetadata
|
9
|
+
# @return [DateTime]
|
10
|
+
attr_reader :timestamp
|
11
|
+
# @return [OpenStruct] Additional properties unmapped to the current class definition
|
12
|
+
attr_reader :additional_properties
|
13
|
+
# @return [Object]
|
14
|
+
attr_reader :_field_set
|
15
|
+
protected :_field_set
|
16
|
+
|
17
|
+
OMIT = Object.new
|
18
|
+
|
19
|
+
# @param timestamp [DateTime]
|
20
|
+
# @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition
|
21
|
+
# @return [Pinnacle::MessageMetadata]
|
22
|
+
def initialize(timestamp:, additional_properties: nil)
|
23
|
+
@timestamp = timestamp
|
24
|
+
@additional_properties = additional_properties
|
25
|
+
@_field_set = { "timestamp": timestamp }
|
26
|
+
end
|
27
|
+
|
28
|
+
# Deserialize a JSON object to an instance of MessageMetadata
|
29
|
+
#
|
30
|
+
# @param json_object [String]
|
31
|
+
# @return [Pinnacle::MessageMetadata]
|
32
|
+
def self.from_json(json_object:)
|
33
|
+
struct = JSON.parse(json_object, object_class: OpenStruct)
|
34
|
+
parsed_json = JSON.parse(json_object)
|
35
|
+
timestamp = (DateTime.parse(parsed_json["timestamp"]) unless parsed_json["timestamp"].nil?)
|
36
|
+
new(timestamp: timestamp, additional_properties: struct)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Serialize an instance of MessageMetadata to a JSON object
|
40
|
+
#
|
41
|
+
# @return [String]
|
42
|
+
def to_json(*_args)
|
43
|
+
@_field_set&.to_json
|
44
|
+
end
|
45
|
+
|
46
|
+
# Leveraged for Union-type generation, validate_raw attempts to parse the given
|
47
|
+
# hash and check each fields type against the current object's property
|
48
|
+
# definitions.
|
49
|
+
#
|
50
|
+
# @param obj [Object]
|
51
|
+
# @return [Void]
|
52
|
+
def self.validate_raw(obj:)
|
53
|
+
obj.timestamp.is_a?(DateTime) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|