60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/pushpad/sender.rb', line 60
def update(attributes)
raise "You must set id" unless id
endpoint = "https://pushpad.xyz/api/v1/senders/#{id}"
response = Request.patch(endpoint, attributes.to_json)
unless response.code == "200"
raise UpdateError, "Response #{response.code} #{response.message}: #{response.body}"
end
updated = self.class.new(JSON.parse(response.body, symbolize_names: true))
ATTRIBUTES.each do |attr|
self.instance_variable_set("@#{attr}", updated.instance_variable_get("@#{attr}"))
end
self
end
|