Class: Io::Flow::V0::Models::ScheduledExport

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Overview

Allows a user to create a scheduled export that will be delivered on a schedule (currently only support once / day at a set time)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ ScheduledExport

Returns a new instance of ScheduledExport.



60349
60350
60351
60352
60353
60354
60355
60356
60357
60358
60359
60360
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60349

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:id, :user, :organization_q, :hour, :minute, :timezone, :types], 'ScheduledExport')
  @id = HttpClient::Preconditions.assert_class('id', opts.delete(:id), String)
  @user = (x = opts.delete(:user); x.is_a?(::Io::Flow::V0::Models::UserReference) ? x : ::Io::Flow::V0::Models::UserReference.new(x))
  @organization_q = HttpClient::Preconditions.assert_class('organization_q', opts.delete(:organization_q), String)
  @hour = HttpClient::Preconditions.assert_class('hour', opts.delete(:hour), Integer)
  @minute = HttpClient::Preconditions.assert_class('minute', opts.delete(:minute), Integer)
  @timezone = HttpClient::Preconditions.assert_class('timezone', opts.delete(:timezone), String)
  @types = HttpClient::Preconditions.assert_class('types', opts.delete(:types), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::ExportType) ? x : ::Io::Flow::V0::Models::ExportType.from_json(x)) }
  @last_sent_at = (x = opts.delete(:last_sent_at); x.nil? ? nil : HttpClient::Preconditions.assert_class('last_sent_at', HttpClient::Helper.to_date_time_iso8601(x), DateTime))
end

Instance Attribute Details

#hourObject (readonly)

Returns the value of attribute hour.



60347
60348
60349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60347

def hour
  @hour
end

#idObject (readonly)

Returns the value of attribute id.



60347
60348
60349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60347

def id
  @id
end

#last_sent_atObject (readonly)

Returns the value of attribute last_sent_at.



60347
60348
60349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60347

def last_sent_at
  @last_sent_at
end

#minuteObject (readonly)

Returns the value of attribute minute.



60347
60348
60349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60347

def minute
  @minute
end

#organization_qObject (readonly)

Returns the value of attribute organization_q.



60347
60348
60349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60347

def organization_q
  @organization_q
end

#timezoneObject (readonly)

Returns the value of attribute timezone.



60347
60348
60349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60347

def timezone
  @timezone
end

#typesObject (readonly)

Returns the value of attribute types.



60347
60348
60349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60347

def types
  @types
end

#userObject (readonly)

Returns the value of attribute user.



60347
60348
60349
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60347

def user
  @user
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



60366
60367
60368
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60366

def copy(incoming={})
  ScheduledExport.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



60370
60371
60372
60373
60374
60375
60376
60377
60378
60379
60380
60381
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60370

def to_hash
  {
    :id => id,
    :user => user.to_hash,
    :organization_q => organization_q,
    :hour => hour,
    :minute => minute,
    :timezone => timezone,
    :types => types.map { |o| o.to_hash },
    :last_sent_at => last_sent_at
  }
end

#to_jsonObject



60362
60363
60364
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 60362

def to_json
  JSON.dump(to_hash)
end