From a018d0cdb6fb05a84009b9032b52d1ba7c3a29a3 Mon Sep 17 00:00:00 2001 From: Christopher Che Date: Wed, 10 Jul 2019 12:15:08 -0400 Subject: [PATCH] Fix bad rebase * Re-add merging pull requests 4, 5, and 6 --- lib/nylas/event.rb | 13 +++++++++++++ lib/nylas/file.rb | 6 +++++- lib/nylas/timespan.rb | 6 +++--- lib/nylas/types.rb | 2 +- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/lib/nylas/event.rb b/lib/nylas/event.rb index 2720769e..92197457 100644 --- a/lib/nylas/event.rb +++ b/lib/nylas/event.rb @@ -40,6 +40,19 @@ def read_only? read_only end + def save + result = if persisted? + raise ModelNotUpdatableError, self unless updatable? + + payload = JSON.parse(attributes.serialize) + payload["when"] = payload["when"].except("object") + execute(method: :put, payload: payload.to_json, path: resource_path) + else + create + end + attributes.merge(result) + end + def rsvp(status, notify_participants:) rsvp = Rsvp.new(api: api, status: status, notify_participants: notify_participants, event_id: id, account_id: account_id) diff --git a/lib/nylas/file.rb b/lib/nylas/file.rb index bac57ad0..fff2f74a 100644 --- a/lib/nylas/file.rb +++ b/lib/nylas/file.rb @@ -46,8 +46,12 @@ def save true end + def download_raw + api.get(path: "#{resource_path}/download") + end + private def retrieve_file - response = api.get(path: "#{resource_path}/download") + response = download_raw filename = response.headers.fetch(:content_disposition, "").gsub("attachment; filename=", "") temp_file = Tempfile.new(filename) temp_file.write(response.body) diff --git a/lib/nylas/timespan.rb b/lib/nylas/timespan.rb index c4a6efe8..ed379317 100644 --- a/lib/nylas/timespan.rb +++ b/lib/nylas/timespan.rb @@ -9,9 +9,9 @@ class Timespan attribute :start_time, :unix_timestamp attribute :end_time, :unix_timestamp attribute :time, :unix_timestamp - attribute :date, :unix_timestamp - attribute :start_date, :unix_timestamp - attribute :end_date, :unix_timestamp + attribute :date, :string + attribute :start_date, :string + attribute :end_date, :string def_delegators :range, :cover? diff --git a/lib/nylas/types.rb b/lib/nylas/types.rb index ca1a025d..5b8ce079 100644 --- a/lib/nylas/types.rb +++ b/lib/nylas/types.rb @@ -88,7 +88,7 @@ def deserialize(object) end def serialize(object) - object.to_i + object.to_i unless object.nil? end end Types.registry[:unix_timestamp] = UnixTimestampType.new