Skip to content

Commit af1a766

Browse files
CopilotJackTelford
andcommitted
Migrate ProcessAutomationApi models to new patterns: sealed classes, IEnumerable collections
Co-authored-by: JackTelford <142545189+JackTelford@users.noreply.github.com>
1 parent 582335c commit af1a766

2 files changed

Lines changed: 4 additions & 515 deletions

File tree

Lines changed: 2 additions & 247 deletions
Original file line numberDiff line numberDiff line change
@@ -1,258 +1,13 @@
1-
using System.Text;
2-
using System.Text.Json.Serialization;
3-
41
namespace PureCloud.Client.Models;
52

6-
/// <summary>
7-
/// CreateTriggerRequest
8-
/// </summary>
9-
10-
public partial class CreateTriggerRequest : IEquatable<CreateTriggerRequest>
3+
public sealed class CreateTriggerRequest
114
{
12-
13-
/// <summary>
14-
/// Initializes a new instance of the <see cref="CreateTriggerRequest" /> class.
15-
/// </summary>
16-
[JsonConstructorAttribute]
17-
protected CreateTriggerRequest() { }
18-
/// <summary>
19-
/// Initializes a new instance of the <see cref="CreateTriggerRequest" /> class.
20-
/// </summary>
21-
/// <param name="Target">The target to invoke when a matching event is received (required).</param>
22-
/// <param name="Enabled">Boolean indicating if Trigger is enabled (required).</param>
23-
/// <param name="MatchCriteria">The configuration for when a trigger is considered to be a match for an event. When not provided, all events will fire the trigger.</param>
24-
/// <param name="Name">The name of the trigger (required).</param>
25-
/// <param name="TopicName">The topic that will cause the trigger to be invoked. Cannot be updated after creation. Valid topics can be found at /processautomation/triggers/topics (required).</param>
26-
/// <param name="EventTTLSeconds">Optional length of time that events are meaningful after origination. Events older than this threshold may be dropped if the platform is delayed in processing events. Unset means events are valid indefinitely, otherwise must be set to at least 10 seconds. Only one of eventTTLSeconds or delayBySeconds can be set..</param>
27-
/// <param name="DelayBySeconds">Optional delay invoking target after trigger fires. Must be in the range of 60 to 900 seconds. Only one of eventTTLSeconds or delayBySeconds can be set..</param>
28-
/// <param name="Description">Description of the trigger. Can be up to 512 characters in length..</param>
29-
public CreateTriggerRequest(TriggerTarget Target = null, bool? Enabled = null, List<MatchCriteria> MatchCriteria = null, string Name = null, string TopicName = null, int? EventTTLSeconds = null, int? DelayBySeconds = null, string Description = null)
30-
{
31-
this.Target = Target;
32-
this.Enabled = Enabled;
33-
this.MatchCriteria = MatchCriteria;
34-
this.Name = Name;
35-
this.TopicName = TopicName;
36-
this.EventTTLSeconds = EventTTLSeconds;
37-
this.DelayBySeconds = DelayBySeconds;
38-
this.Description = Description;
39-
40-
}
41-
42-
43-
44-
/// <summary>
45-
/// The target to invoke when a matching event is received
46-
/// </summary>
47-
/// <value>The target to invoke when a matching event is received</value>
48-
[JsonPropertyName("target")]
495
public TriggerTarget Target { get; set; }
50-
51-
52-
53-
/// <summary>
54-
/// Boolean indicating if Trigger is enabled
55-
/// </summary>
56-
/// <value>Boolean indicating if Trigger is enabled</value>
57-
[JsonPropertyName("enabled")]
586
public bool? Enabled { get; set; }
59-
60-
61-
62-
/// <summary>
63-
/// The configuration for when a trigger is considered to be a match for an event. When not provided, all events will fire the trigger
64-
/// </summary>
65-
/// <value>The configuration for when a trigger is considered to be a match for an event. When not provided, all events will fire the trigger</value>
66-
[JsonPropertyName("matchCriteria")]
67-
public List<MatchCriteria> MatchCriteria { get; set; }
68-
69-
70-
71-
/// <summary>
72-
/// The name of the trigger
73-
/// </summary>
74-
/// <value>The name of the trigger</value>
75-
[JsonPropertyName("name")]
7+
public IEnumerable<MatchCriteria> MatchCriteria { get; set; }
768
public string Name { get; set; }
77-
78-
79-
80-
/// <summary>
81-
/// The topic that will cause the trigger to be invoked. Cannot be updated after creation. Valid topics can be found at /processautomation/triggers/topics
82-
/// </summary>
83-
/// <value>The topic that will cause the trigger to be invoked. Cannot be updated after creation. Valid topics can be found at /processautomation/triggers/topics </value>
84-
[JsonPropertyName("topicName")]
859
public string TopicName { get; set; }
86-
87-
88-
89-
/// <summary>
90-
/// Optional length of time that events are meaningful after origination. Events older than this threshold may be dropped if the platform is delayed in processing events. Unset means events are valid indefinitely, otherwise must be set to at least 10 seconds. Only one of eventTTLSeconds or delayBySeconds can be set.
91-
/// </summary>
92-
/// <value>Optional length of time that events are meaningful after origination. Events older than this threshold may be dropped if the platform is delayed in processing events. Unset means events are valid indefinitely, otherwise must be set to at least 10 seconds. Only one of eventTTLSeconds or delayBySeconds can be set.</value>
93-
[JsonPropertyName("eventTTLSeconds")]
9410
public int? EventTTLSeconds { get; set; }
95-
96-
97-
98-
/// <summary>
99-
/// Optional delay invoking target after trigger fires. Must be in the range of 60 to 900 seconds. Only one of eventTTLSeconds or delayBySeconds can be set.
100-
/// </summary>
101-
/// <value>Optional delay invoking target after trigger fires. Must be in the range of 60 to 900 seconds. Only one of eventTTLSeconds or delayBySeconds can be set.</value>
102-
[JsonPropertyName("delayBySeconds")]
10311
public int? DelayBySeconds { get; set; }
104-
105-
106-
107-
/// <summary>
108-
/// Description of the trigger. Can be up to 512 characters in length.
109-
/// </summary>
110-
/// <value>Description of the trigger. Can be up to 512 characters in length.</value>
111-
[JsonPropertyName("description")]
11212
public string Description { get; set; }
113-
114-
115-
/// <summary>
116-
/// Returns the string presentation of the object
117-
/// </summary>
118-
/// <returns>String presentation of the object</returns>
119-
public override string ToString()
120-
{
121-
var sb = new StringBuilder();
122-
sb.Append("class CreateTriggerRequest {\n");
123-
124-
sb.Append(" Target: ").Append(Target).Append("\n");
125-
sb.Append(" Enabled: ").Append(Enabled).Append("\n");
126-
sb.Append(" MatchCriteria: ").Append(MatchCriteria).Append("\n");
127-
sb.Append(" Name: ").Append(Name).Append("\n");
128-
sb.Append(" TopicName: ").Append(TopicName).Append("\n");
129-
sb.Append(" EventTTLSeconds: ").Append(EventTTLSeconds).Append("\n");
130-
sb.Append(" DelayBySeconds: ").Append(DelayBySeconds).Append("\n");
131-
sb.Append(" Description: ").Append(Description).Append("\n");
132-
sb.Append("}\n");
133-
return sb.ToString();
134-
}
135-
136-
137-
/// <summary>
138-
/// Returns true if objects are equal
139-
/// </summary>
140-
/// <param name="obj">Object to be compared</param>
141-
/// <returns>Boolean</returns>
142-
public override bool Equals(object obj)
143-
{
144-
// credit: http://stackoverflow.com/a/10454552/677735
145-
return Equals(obj as CreateTriggerRequest);
146-
}
147-
148-
/// <summary>
149-
/// Returns true if CreateTriggerRequest instances are equal
150-
/// </summary>
151-
/// <param name="other">Instance of CreateTriggerRequest to be compared</param>
152-
/// <returns>Boolean</returns>
153-
public bool Equals(CreateTriggerRequest other)
154-
{
155-
// credit: http://stackoverflow.com/a/10454552/677735
156-
if (other == null)
157-
{
158-
return false;
159-
}
160-
161-
return true &&
162-
(
163-
Target == other.Target ||
164-
Target != null &&
165-
Target.Equals(other.Target)
166-
) &&
167-
(
168-
Enabled == other.Enabled ||
169-
Enabled != null &&
170-
Enabled.Equals(other.Enabled)
171-
) &&
172-
(
173-
MatchCriteria == other.MatchCriteria ||
174-
MatchCriteria != null &&
175-
MatchCriteria.SequenceEqual(other.MatchCriteria)
176-
) &&
177-
(
178-
Name == other.Name ||
179-
Name != null &&
180-
Name.Equals(other.Name)
181-
) &&
182-
(
183-
TopicName == other.TopicName ||
184-
TopicName != null &&
185-
TopicName.Equals(other.TopicName)
186-
) &&
187-
(
188-
EventTTLSeconds == other.EventTTLSeconds ||
189-
EventTTLSeconds != null &&
190-
EventTTLSeconds.Equals(other.EventTTLSeconds)
191-
) &&
192-
(
193-
DelayBySeconds == other.DelayBySeconds ||
194-
DelayBySeconds != null &&
195-
DelayBySeconds.Equals(other.DelayBySeconds)
196-
) &&
197-
(
198-
Description == other.Description ||
199-
Description != null &&
200-
Description.Equals(other.Description)
201-
);
202-
}
203-
204-
/// <summary>
205-
/// Gets the hash code
206-
/// </summary>
207-
/// <returns>Hash code</returns>
208-
public override int GetHashCode()
209-
{
210-
// credit: http://stackoverflow.com/a/263416/677735
211-
unchecked // Overflow is fine, just wrap
212-
{
213-
int hash = 41;
214-
// Suitable nullity checks etc, of course :)
215-
if (Target != null)
216-
{
217-
hash = hash * 59 + Target.GetHashCode();
218-
}
219-
220-
if (Enabled != null)
221-
{
222-
hash = hash * 59 + Enabled.GetHashCode();
223-
}
224-
225-
if (MatchCriteria != null)
226-
{
227-
hash = hash * 59 + MatchCriteria.GetHashCode();
228-
}
229-
230-
if (Name != null)
231-
{
232-
hash = hash * 59 + Name.GetHashCode();
233-
}
234-
235-
if (TopicName != null)
236-
{
237-
hash = hash * 59 + TopicName.GetHashCode();
238-
}
239-
240-
if (EventTTLSeconds != null)
241-
{
242-
hash = hash * 59 + EventTTLSeconds.GetHashCode();
243-
}
244-
245-
if (DelayBySeconds != null)
246-
{
247-
hash = hash * 59 + DelayBySeconds.GetHashCode();
248-
}
249-
250-
if (Description != null)
251-
{
252-
hash = hash * 59 + Description.GetHashCode();
253-
}
254-
255-
return hash;
256-
}
257-
}
25813
}

0 commit comments

Comments
 (0)