Class: Mosaic::Lyris::Upload
- Defined in:
- lib/mosaic/lyris/upload.rb
Instance Attribute Summary collapse
-
#bytes_processed ⇒ Object
readonly
Returns the value of attribute bytes_processed.
-
#completed_at ⇒ Object
readonly
Returns the value of attribute completed_at.
-
#estimated_complete_at ⇒ Object
readonly
Returns the value of attribute estimated_complete_at.
-
#list_id ⇒ Object
readonly
Returns the value of attribute list_id.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#time_elapsed ⇒ Object
readonly
Returns the value of attribute time_elapsed.
-
#time_remaining ⇒ Object
readonly
Returns the value of attribute time_remaining.
Class Method Summary collapse
- .add(email, file, options = {}) ⇒ Object
- .build(record, options = {}) ⇒ Object
- .query(what, options = {}) ⇒ Object
- .validate_options!(options) ⇒ Object
Instance Method Summary collapse
- #active? ⇒ Boolean
- #done? ⇒ Boolean
- #fatal? ⇒ Boolean
- #incomplete? ⇒ Boolean
- #pending? ⇒ Boolean
- #retry? ⇒ Boolean
Methods inherited from Object
callback_url, configuration, configuration=, default_list_id, default_trigger_id, get_array_data, get_boolean_data, get_data, get_date_data, get_demographic_data, get_element, get_integer_data, get_integer_element, get_time_data, get_time_element, get_time_offset_data, get_xml_time_data, #initialize, load_configuration, logger, logger=, password, post, put_array_data, put_data, put_demographic_data, put_extra_data, server, site_id, #to_param, triggers
Constructor Details
This class inherits a constructor from Mosaic::Lyris::Object
Instance Attribute Details
#bytes_processed ⇒ Object (readonly)
Returns the value of attribute bytes_processed.
4 5 6 |
# File 'lib/mosaic/lyris/upload.rb', line 4 def bytes_processed @bytes_processed end |
#completed_at ⇒ Object (readonly)
Returns the value of attribute completed_at.
4 5 6 |
# File 'lib/mosaic/lyris/upload.rb', line 4 def completed_at @completed_at end |
#estimated_complete_at ⇒ Object (readonly)
Returns the value of attribute estimated_complete_at.
4 5 6 |
# File 'lib/mosaic/lyris/upload.rb', line 4 def estimated_complete_at @estimated_complete_at end |
#list_id ⇒ Object (readonly)
Returns the value of attribute list_id.
4 5 6 |
# File 'lib/mosaic/lyris/upload.rb', line 4 def list_id @list_id end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
4 5 6 |
# File 'lib/mosaic/lyris/upload.rb', line 4 def size @size end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/mosaic/lyris/upload.rb', line 4 def status @status end |
#time_elapsed ⇒ Object (readonly)
Returns the value of attribute time_elapsed.
4 5 6 |
# File 'lib/mosaic/lyris/upload.rb', line 4 def time_elapsed @time_elapsed end |
#time_remaining ⇒ Object (readonly)
Returns the value of attribute time_remaining.
4 5 6 |
# File 'lib/mosaic/lyris/upload.rb', line 4 def time_remaining @time_remaining end |
Class Method Details
.add(email, file, options = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/mosaic/lyris/upload.rb', line 38 def add(email, file, = {}) () reply = post('record', 'upload') do |request| request.MLID [:list_id] || '' put_data(request, 'email', email) put_extra_data(request, 'file', file) put_extra_data(request, 'type', [:type] || 'active') put_extra_data(request, 'trigger', 'yes') if [:trigger] if [:update] put_extra_data(request, 'update', [:update].to_s == 'only' ? 'only' : 'on') put_extra_data(request, 'delete_blank', 'on') if [:blank] put_extra_data(request, 'untrash', 'on') if [:untrash] end put_extra_data(request, 'validate', 'on') if [:validate] end new(.merge(:id => reply.at('/DATASET/DATA').inner_html, :email => [:email], :file => file, :type => [:type] || 'active')) end |
.build(record, options = {}) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/mosaic/lyris/upload.rb', line 56 def build(record, = {}) new :list_id => [:list_id], :file => get_element(record, 'FILE'), :status => get_element(record, 'STATUS'), :size => get_integer_element(record, 'SIZE'), :bytes_processed => get_integer_element(record, 'PROCESSED'), :time_elapsed => get_integer_element(record, 'ELAPSED'), :time_remaining => get_integer_element(record, 'TIMELEFT'), :estimated_complete_at => get_time_element(record, 'ETC'), :completed_at => get_time_element(record, 'TIME') end |
.query(what, options = {}) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/mosaic/lyris/upload.rb', line 68 def query(what, = {}) reply = post('record', 'upload-status') do |request| request.MLID [:list_id] || '' put_extra_data(request, 'file', what) unless what.to_s == 'all' end if what.to_s == 'all' reply.search('/DATASET/*').collect do |record| build record, end else build reply.at('/DATASET/DATASET_1'), end end |
.validate_options!(options) ⇒ Object
82 83 84 85 |
# File 'lib/mosaic/lyris/upload.rb', line 82 def () raise ArgumentError, "expected type of :active, :proof, :unsubscribed, :bounced, :trashed or :globalunsubscribe; got #{[:type]}" unless %w(active proof unsubscribed bounced trashed globalunsubscribe).include?([:type].to_s) if [:type] raise ArgumentError, "expected update value of true or :only; for #{[:update]}" unless %w(true only).include?([:update].to_s) if [:update] end |
Instance Method Details
#active? ⇒ Boolean
21 22 23 |
# File 'lib/mosaic/lyris/upload.rb', line 21 def active? status =~ /^[0-9]+%$/ end |
#done? ⇒ Boolean
13 14 15 |
# File 'lib/mosaic/lyris/upload.rb', line 13 def done? status == 'done' end |
#fatal? ⇒ Boolean
17 18 19 |
# File 'lib/mosaic/lyris/upload.rb', line 17 def fatal? status == 'fatal' end |
#incomplete? ⇒ Boolean
25 26 27 |
# File 'lib/mosaic/lyris/upload.rb', line 25 def incomplete? pending? || active? end |
#pending? ⇒ Boolean
29 30 31 |
# File 'lib/mosaic/lyris/upload.rb', line 29 def pending? status == 'pending' end |
#retry? ⇒ Boolean
33 34 35 |
# File 'lib/mosaic/lyris/upload.rb', line 33 def retry? status == 'retry' end |