govdelivery-tms 0.9.3 → 0.9.4

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Zjc4MDEyNGFmZjllYzk4ZTc4MGE4ZTY0NmY0MThiNjM1OTQ2ZTIyZg==
4
+ OGU2YjhiZjAxYTBmOWZjNGRiOGEzYmJmM2JiYmFhNjVkY2U4NGJmYw==
5
5
  data.tar.gz: !binary |-
6
- NGMxYjBiNDNjN2RlODIzYTJiYTRiZmE0ZWIxNDg4OTAwZmUzYzg3Yw==
6
+ Y2EzNjAyZDA5MWRiZmYyYzBmMzkyZWYyYzc5NDQ1MjMwZjY1NmM5NA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZjA1Yjk5MmQyNTZmZTZkMmM2YjVmMDNmYmYxMDY5MWRiNTFmZjk0MTg0MzNh
10
- NjViZjYxNTc3MzI5OTJjYWE2NjIzZmUwMjA5MTI4MWQ1OGI5ZTM5Yzg1ODRh
11
- ZTZhYjIxMTJhZjc0MjViODkwY2ZiMTZlYzNmMmY3MTU5NjE5MjE=
9
+ M2ZhODFhYmQxZTZkMmI1MmU3NzA3OGNlNzFkMDlkMmQ1MTYwOWViMWNkYWRh
10
+ Yzg5ZDI4Y2I5ZDZlZGE1OTQyYWZkNjAxNmJkOWFmYTU1NWNjMzIxYTM1ZmUx
11
+ ZmI0MTA2MTMwNGIxZWI2YzlkYjQ2YzBlYWI0YjFhMGQ0MDk5NmU=
12
12
  data.tar.gz: !binary |-
13
- MDg1NDNkMmJmMzUzODdhY2YzM2YyMTZjNmUwMGZkM2E4ZTEyMWE2YThmMjMz
14
- NWZmYjZlMjI1MjlmZTFmZDFlM2Y1ZWFmNTQ2OWU3MWIwYzI5MGE1NGNmNmM0
15
- MjUxNDdmMGI1MTNmZTlhYjc5ZmJkMTM5MWZjODlmY2QwZTk5MDI=
13
+ MmJmNzk5ZjRiNWI1OTJiNjIyYTFmMDY0MTgyZmFhZmQ1ZWQxNzA4YmZmMmU5
14
+ ZjZmMWUzMDUwZTJhMGY3NGQzNjE3ZTAzZjVhNmNlMGRkNGU0NDU5MTBlODUw
15
+ NTM0ZDE0ZDU4ZDFkODZhNWE0MzEyYmVmMWY3NTA3NzEwMzQ2ZWE=
@@ -44,6 +44,17 @@ module GovDelivery::TMS::InstanceResource
44
44
  @readonly_attributes
45
45
  end
46
46
 
47
+ ##
48
+ # Nullable attributes are sent as null in the request
49
+ #
50
+ def nullable_attributes(*attrs)
51
+ @nullable_attributes ||= []
52
+ if attrs.any?
53
+ @nullable_attributes.map!(&:to_sym).concat(attrs).uniq! if attrs.any?
54
+ end
55
+ @nullable_attributes
56
+ end
57
+
47
58
  ##
48
59
  # For collections that are represented as attributes (i.e. inline, no href)
49
60
  #
@@ -166,7 +177,9 @@ module GovDelivery::TMS::InstanceResource
166
177
  json_hash[:_links] ||= {}
167
178
  json_hash[:_links][attr] = @links[attr]
168
179
  end
169
- json_hash.reject { |_, value| value.nil? }
180
+ json_hash.reject do |key, value|
181
+ value.nil? && !self.class.nullable_attributes.include?(key)
182
+ end
170
183
  end
171
184
 
172
185
  protected
@@ -18,5 +18,7 @@ module GovDelivery::TMS #:nodoc:
18
18
  readonly_attributes :id, :created_at
19
19
 
20
20
  collection_attribute :from_address, 'FromAddress'
21
+
22
+ nullable_attributes :message_type_code
21
23
  end
22
24
  end
@@ -1,5 +1,5 @@
1
1
  module GovDelivery
2
2
  module TMS #:nodoc:
3
- VERSION = '0.9.3'
3
+ VERSION = '0.9.4'.freeze
4
4
  end
5
5
  end
@@ -35,6 +35,14 @@ describe GovDelivery::TMS::InstanceResource do
35
35
  expect(@instance_resource.to_json).to eq({blah: {recipients: [], opened: [], clicked: [], sent: [], failed: []}})
36
36
  end
37
37
 
38
+ it 'should ignore nils in to_json unless an attribute in nullable_attributes' do
39
+ @instance_resource.class.nullable_attributes :bar
40
+ @instance_resource.bar = nil
41
+ expect(@instance_resource.to_json).to eq({blah: {recipients: [], opened: [], clicked: [], sent: [], failed: []},
42
+ bar: nil})
43
+ @instance_resource.class.instance_variable_set :@nullable_attributes, []
44
+ end
45
+
38
46
  it 'should not GET on initialization' do
39
47
  expect(client).not_to receive(:get)
40
48
  Foo.new(client, 'https://example.com/foos/1')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govdelivery-tms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - GovDelivery