phrase 1.0.4 → 1.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,194 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class BranchName
5
+ attr_accessor :name
6
+
7
+ # Attribute mapping from ruby-style variable name to JSON key.
8
+ def self.attribute_map
9
+ {
10
+ :'name' => :'name'
11
+ }
12
+ end
13
+
14
+ # Attribute type mapping.
15
+ def self.openapi_types
16
+ {
17
+ :'name' => :'String'
18
+ }
19
+ end
20
+
21
+ # List of attributes with nullable: true
22
+ def self.openapi_nullable
23
+ Set.new([
24
+ ])
25
+ end
26
+
27
+ # Initializes the object
28
+ # @param [Hash] attributes Model attributes in the form of hash
29
+ def initialize(attributes = {})
30
+ if (!attributes.is_a?(Hash))
31
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::BranchName` initialize method"
32
+ end
33
+
34
+ # check to see if the attribute exists and convert string to symbol for hash key
35
+ attributes = attributes.each_with_object({}) { |(k, v), h|
36
+ if (!self.class.attribute_map.key?(k.to_sym))
37
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::BranchName`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
38
+ end
39
+ h[k.to_sym] = v
40
+ }
41
+
42
+ if attributes.key?(:'name')
43
+ self.name = attributes[:'name']
44
+ end
45
+ end
46
+
47
+ # Show invalid properties with the reasons. Usually used together with valid?
48
+ # @return Array for valid properties with the reasons
49
+ def list_invalid_properties
50
+ invalid_properties = Array.new
51
+ invalid_properties
52
+ end
53
+
54
+ # Check to see if the all the properties in the model are valid
55
+ # @return true if the model is valid
56
+ def valid?
57
+ true
58
+ end
59
+
60
+ # Checks equality by comparing each attribute.
61
+ # @param [Object] Object to be compared
62
+ def ==(o)
63
+ return true if self.equal?(o)
64
+ self.class == o.class &&
65
+ name == o.name
66
+ end
67
+
68
+ # @see the `==` method
69
+ # @param [Object] Object to be compared
70
+ def eql?(o)
71
+ self == o
72
+ end
73
+
74
+ # Calculates hash code according to all attributes.
75
+ # @return [Integer] Hash code
76
+ def hash
77
+ [name].hash
78
+ end
79
+
80
+ # Builds the object from hash
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ # @return [Object] Returns the model itself
83
+ def self.build_from_hash(attributes)
84
+ new.build_from_hash(attributes)
85
+ end
86
+
87
+ # Builds the object from hash
88
+ # @param [Hash] attributes Model attributes in the form of hash
89
+ # @return [Object] Returns the model itself
90
+ def build_from_hash(attributes)
91
+ return nil unless attributes.is_a?(Hash)
92
+ self.class.openapi_types.each_pair do |key, type|
93
+ if type =~ /\AArray<(.*)>/i
94
+ # check to ensure the input is an array given that the attribute
95
+ # is documented as an array but the input is not
96
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
97
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
98
+ end
99
+ elsif !attributes[self.class.attribute_map[key]].nil?
100
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
101
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
102
+ end
103
+
104
+ self
105
+ end
106
+
107
+ # Deserializes the data based on type
108
+ # @param string type Data type
109
+ # @param string value Value to be deserialized
110
+ # @return [Object] Deserialized data
111
+ def _deserialize(type, value)
112
+ case type.to_sym
113
+ when :DateTime
114
+ DateTime.parse(value)
115
+ when :Date
116
+ Date.parse(value)
117
+ when :String
118
+ value.to_s
119
+ when :Integer
120
+ value.to_i
121
+ when :Float
122
+ value.to_f
123
+ when :Boolean
124
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
125
+ true
126
+ else
127
+ false
128
+ end
129
+ when :Object
130
+ # generic object (usually a Hash), return directly
131
+ value
132
+ when /\AArray<(?<inner_type>.+)>\z/
133
+ inner_type = Regexp.last_match[:inner_type]
134
+ value.map { |v| _deserialize(inner_type, v) }
135
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
136
+ k_type = Regexp.last_match[:k_type]
137
+ v_type = Regexp.last_match[:v_type]
138
+ {}.tap do |hash|
139
+ value.each do |k, v|
140
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
141
+ end
142
+ end
143
+ else # model
144
+ Phrase.const_get(type).build_from_hash(value)
145
+ end
146
+ end
147
+
148
+ # Returns the string representation of the object
149
+ # @return [String] String presentation of the object
150
+ def to_s
151
+ to_hash.to_s
152
+ end
153
+
154
+ # to_body is an alias to to_hash (backward compatibility)
155
+ # @return [Hash] Returns the object in the form of hash
156
+ def to_body
157
+ to_hash
158
+ end
159
+
160
+ # Returns the object in the form of hash
161
+ # @return [Hash] Returns the object in the form of hash
162
+ def to_hash
163
+ hash = {}
164
+ self.class.attribute_map.each_pair do |attr, param|
165
+ value = self.send(attr)
166
+ if value.nil?
167
+ is_nullable = self.class.openapi_nullable.include?(attr)
168
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
169
+ end
170
+
171
+ hash[param] = _to_hash(value)
172
+ end
173
+ hash
174
+ end
175
+
176
+ # Outputs non-array value in the form of hash
177
+ # For object, use to_hash. Otherwise, just return the value
178
+ # @param [Object] value Any valid value
179
+ # @return [Hash] Returns the value in the form of hash
180
+ def _to_hash(value)
181
+ if value.is_a?(Array)
182
+ value.compact.map { |v| _to_hash(v) }
183
+ elsif value.is_a?(Hash)
184
+ {}.tap do |hash|
185
+ value.each { |k, v| hash[k] = _to_hash(v) }
186
+ end
187
+ elsif value.respond_to? :to_hash
188
+ value.to_hash
189
+ else
190
+ value
191
+ end
192
+ end
193
+ end
194
+ end
@@ -14,6 +14,10 @@ module Phrase
14
14
 
15
15
  attr_accessor :ticket_url
16
16
 
17
+ attr_accessor :project
18
+
19
+ attr_accessor :branch
20
+
17
21
  attr_accessor :created_at
18
22
 
19
23
  attr_accessor :updated_at
@@ -27,6 +31,8 @@ module Phrase
27
31
  :'due_date' => :'due_date',
28
32
  :'state' => :'state',
29
33
  :'ticket_url' => :'ticket_url',
34
+ :'project' => :'project',
35
+ :'branch' => :'branch',
30
36
  :'created_at' => :'created_at',
31
37
  :'updated_at' => :'updated_at'
32
38
  }
@@ -41,6 +47,8 @@ module Phrase
41
47
  :'due_date' => :'DateTime',
42
48
  :'state' => :'String',
43
49
  :'ticket_url' => :'String',
50
+ :'project' => :'ProjectShort',
51
+ :'branch' => :'BranchName',
44
52
  :'created_at' => :'DateTime',
45
53
  :'updated_at' => :'DateTime'
46
54
  }
@@ -91,6 +99,14 @@ module Phrase
91
99
  self.ticket_url = attributes[:'ticket_url']
92
100
  end
93
101
 
102
+ if attributes.key?(:'project')
103
+ self.project = attributes[:'project']
104
+ end
105
+
106
+ if attributes.key?(:'branch')
107
+ self.branch = attributes[:'branch']
108
+ end
109
+
94
110
  if attributes.key?(:'created_at')
95
111
  self.created_at = attributes[:'created_at']
96
112
  end
@@ -124,6 +140,8 @@ module Phrase
124
140
  due_date == o.due_date &&
125
141
  state == o.state &&
126
142
  ticket_url == o.ticket_url &&
143
+ project == o.project &&
144
+ branch == o.branch &&
127
145
  created_at == o.created_at &&
128
146
  updated_at == o.updated_at
129
147
  end
@@ -137,7 +155,7 @@ module Phrase
137
155
  # Calculates hash code according to all attributes.
138
156
  # @return [Integer] Hash code
139
157
  def hash
140
- [id, name, briefing, due_date, state, ticket_url, created_at, updated_at].hash
158
+ [id, name, briefing, due_date, state, ticket_url, project, branch, created_at, updated_at].hash
141
159
  end
142
160
 
143
161
  # Builds the object from hash
@@ -14,6 +14,10 @@ module Phrase
14
14
 
15
15
  attr_accessor :ticket_url
16
16
 
17
+ attr_accessor :project
18
+
19
+ attr_accessor :branch
20
+
17
21
  attr_accessor :created_at
18
22
 
19
23
  attr_accessor :updated_at
@@ -35,6 +39,8 @@ module Phrase
35
39
  :'due_date' => :'due_date',
36
40
  :'state' => :'state',
37
41
  :'ticket_url' => :'ticket_url',
42
+ :'project' => :'project',
43
+ :'branch' => :'branch',
38
44
  :'created_at' => :'created_at',
39
45
  :'updated_at' => :'updated_at',
40
46
  :'owner' => :'owner',
@@ -53,6 +59,8 @@ module Phrase
53
59
  :'due_date' => :'DateTime',
54
60
  :'state' => :'String',
55
61
  :'ticket_url' => :'String',
62
+ :'project' => :'ProjectShort',
63
+ :'branch' => :'BranchName',
56
64
  :'created_at' => :'DateTime',
57
65
  :'updated_at' => :'DateTime',
58
66
  :'owner' => :'UserPreview',
@@ -115,6 +123,14 @@ module Phrase
115
123
  self.ticket_url = attributes[:'ticket_url']
116
124
  end
117
125
 
126
+ if attributes.key?(:'project')
127
+ self.project = attributes[:'project']
128
+ end
129
+
130
+ if attributes.key?(:'branch')
131
+ self.branch = attributes[:'branch']
132
+ end
133
+
118
134
  if attributes.key?(:'created_at')
119
135
  self.created_at = attributes[:'created_at']
120
136
  end
@@ -168,6 +184,8 @@ module Phrase
168
184
  due_date == o.due_date &&
169
185
  state == o.state &&
170
186
  ticket_url == o.ticket_url &&
187
+ project == o.project &&
188
+ branch == o.branch &&
171
189
  created_at == o.created_at &&
172
190
  updated_at == o.updated_at &&
173
191
  owner == o.owner &&
@@ -185,7 +203,7 @@ module Phrase
185
203
  # Calculates hash code according to all attributes.
186
204
  # @return [Integer] Hash code
187
205
  def hash
188
- [id, name, briefing, due_date, state, ticket_url, created_at, updated_at, owner, job_tag_name, locales, keys].hash
206
+ [id, name, briefing, due_date, state, ticket_url, project, branch, created_at, updated_at, owner, job_tag_name, locales, keys].hash
189
207
  end
190
208
 
191
209
  # Builds the object from hash
@@ -12,6 +12,8 @@ module Phrase
12
12
 
13
13
  attr_accessor :active
14
14
 
15
+ attr_accessor :include_branches
16
+
15
17
  attr_accessor :created_at
16
18
 
17
19
  attr_accessor :updated_at
@@ -24,6 +26,7 @@ module Phrase
24
26
  :'description' => :'description',
25
27
  :'events' => :'events',
26
28
  :'active' => :'active',
29
+ :'include_branches' => :'include_branches',
27
30
  :'created_at' => :'created_at',
28
31
  :'updated_at' => :'updated_at'
29
32
  }
@@ -37,6 +40,7 @@ module Phrase
37
40
  :'description' => :'String',
38
41
  :'events' => :'Array<String>',
39
42
  :'active' => :'Boolean',
43
+ :'include_branches' => :'Boolean',
40
44
  :'created_at' => :'DateTime',
41
45
  :'updated_at' => :'DateTime'
42
46
  }
@@ -85,6 +89,10 @@ module Phrase
85
89
  self.active = attributes[:'active']
86
90
  end
87
91
 
92
+ if attributes.key?(:'include_branches')
93
+ self.include_branches = attributes[:'include_branches']
94
+ end
95
+
88
96
  if attributes.key?(:'created_at')
89
97
  self.created_at = attributes[:'created_at']
90
98
  end
@@ -117,6 +125,7 @@ module Phrase
117
125
  description == o.description &&
118
126
  events == o.events &&
119
127
  active == o.active &&
128
+ include_branches == o.include_branches &&
120
129
  created_at == o.created_at &&
121
130
  updated_at == o.updated_at
122
131
  end
@@ -130,7 +139,7 @@ module Phrase
130
139
  # Calculates hash code according to all attributes.
131
140
  # @return [Integer] Hash code
132
141
  def hash
133
- [id, callback_url, description, events, active, created_at, updated_at].hash
142
+ [id, callback_url, description, events, active, include_branches, created_at, updated_at].hash
134
143
  end
135
144
 
136
145
  # Builds the object from hash
@@ -5,6 +5,9 @@ module Phrase
5
5
  # Callback URL to send requests to
6
6
  attr_accessor :callback_url
7
7
 
8
+ # Webhook secret used to calculate signature. If empty, the default project secret will be used.
9
+ attr_accessor :secret
10
+
8
11
  # Webhook description
9
12
  attr_accessor :description
10
13
 
@@ -14,13 +17,18 @@ module Phrase
14
17
  # Whether webhook is active or inactive
15
18
  attr_accessor :active
16
19
 
20
+ # If enabled, webhook will also be triggered for events from branches of the project specified.
21
+ attr_accessor :include_branches
22
+
17
23
  # Attribute mapping from ruby-style variable name to JSON key.
18
24
  def self.attribute_map
19
25
  {
20
26
  :'callback_url' => :'callback_url',
27
+ :'secret' => :'secret',
21
28
  :'description' => :'description',
22
29
  :'events' => :'events',
23
- :'active' => :'active'
30
+ :'active' => :'active',
31
+ :'include_branches' => :'include_branches'
24
32
  }
25
33
  end
26
34
 
@@ -28,9 +36,11 @@ module Phrase
28
36
  def self.openapi_types
29
37
  {
30
38
  :'callback_url' => :'String',
39
+ :'secret' => :'String',
31
40
  :'description' => :'String',
32
41
  :'events' => :'String',
33
- :'active' => :'Boolean'
42
+ :'active' => :'Boolean',
43
+ :'include_branches' => :'Boolean'
34
44
  }
35
45
  end
36
46
 
@@ -59,6 +69,10 @@ module Phrase
59
69
  self.callback_url = attributes[:'callback_url']
60
70
  end
61
71
 
72
+ if attributes.key?(:'secret')
73
+ self.secret = attributes[:'secret']
74
+ end
75
+
62
76
  if attributes.key?(:'description')
63
77
  self.description = attributes[:'description']
64
78
  end
@@ -70,6 +84,10 @@ module Phrase
70
84
  if attributes.key?(:'active')
71
85
  self.active = attributes[:'active']
72
86
  end
87
+
88
+ if attributes.key?(:'include_branches')
89
+ self.include_branches = attributes[:'include_branches']
90
+ end
73
91
  end
74
92
 
75
93
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -91,9 +109,11 @@ module Phrase
91
109
  return true if self.equal?(o)
92
110
  self.class == o.class &&
93
111
  callback_url == o.callback_url &&
112
+ secret == o.secret &&
94
113
  description == o.description &&
95
114
  events == o.events &&
96
- active == o.active
115
+ active == o.active &&
116
+ include_branches == o.include_branches
97
117
  end
98
118
 
99
119
  # @see the `==` method
@@ -105,7 +125,7 @@ module Phrase
105
125
  # Calculates hash code according to all attributes.
106
126
  # @return [Integer] Hash code
107
127
  def hash
108
- [callback_url, description, events, active].hash
128
+ [callback_url, secret, description, events, active, include_branches].hash
109
129
  end
110
130
 
111
131
  # Builds the object from hash