Module: Itunes::Receipt::Properties
Constant Summary collapse
- LIST =
{ 'unique_identifier' => true, 'product_id' => true, 'bid' => true, 'unique_vendor_identifier' => true, 'bvrs' => true, 'transaction_id' => proc { |v| v.to_i }, 'original_transaction_id' => proc { |v| v.to_i }, 'quantity' => proc { |v| v.to_i }, 'item_id' => proc { |v| v.to_i }, 'web_order_line_item_id' => proc { |v| v.to_i }, 'original_purchase_date' => { name: 'original_purchase_date_ms', prc: proc { |v| Time.at(v.to_f / 1_000) }, }, 'purchase_date' => { name: 'purchase_date_ms', prc: proc { |v| Time.at(v.to_f / 1_000) }, }, 'expires_date' => { name: [ 'expires_date_ms', 'expires_date' ], prc: proc { |v| Time.at(v.to_f / 1_000) }, }, 'receipt_type' => true, 'adam_id' => proc { |v| v.to_i }, 'app_item_id' => proc { |v| v.to_i }, 'bundle_id' => true, 'application_version' => true, 'download_id' => proc { |v| v.to_i }, 'version_external_identifier' => proc { |v| v.to_i }, 'receipt_creation_date' => { name: 'receipt_creation_date_ms', prc: proc { |v| Time.at(v.to_f / 1_000) }, }, 'request_date' => { name: 'request_date_ms', prc: proc { |v| Time.at(v.to_f / 1_000) }, }, 'original_application_version' => true, 'is_trial_period' => proc { |v| v == 'true' }, }
Class Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/itunes/receipt/properties.rb', line 46 def self.included klass klass.class_eval do attr_reader :data end (LIST.keys & klass::PROPERTY_LIST).each do |prop| case value = LIST[prop] when TrueClass klass.class_eval " def \#{prop}\n data['\#{prop}']\n end\n end;\n when Hash\n case value[:name]\n when String\n klass.class_eval <<-\"end;\", __FILE__, __LINE__+1\n def \#{prop}\n Itunes::Receipt::Properties::LIST['\#{prop}'][:prc][data['\#{value[:name]}']]\n end\n end;\n when Array\n klass.class_eval <<-\"end;\", __FILE__, __LINE__+1\n def \#{prop}\n \#{value[:name]}.reduce(nil) do |res, name|\n if not res and data[name]\n Itunes::Receipt::Properties::LIST['\#{prop}'][:prc][data[name]]\n else\n res\n end\n end\n end\n end;\n end\n when Proc\n klass.class_eval <<-\"end;\", __FILE__, __LINE__+1\n def \#{prop}\n Itunes::Receipt::Properties::LIST['\#{prop}'][data['\#{prop}']]\n end\n end;\n end\n end\nend\n", __FILE__, __LINE__+1 |