shipping_backup_client 1.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 8112194d10fbe85fc25af9a1b6ecd9bf577ef8bc7267c8c2078f6bd86d73bc12
4
+ data.tar.gz: 82f8b4d89a70682a9cc298aa01179376e588cf4d65da4a506d14c0aee266bbb4
5
+ SHA512:
6
+ metadata.gz: 043abad1629e056255a77240a02df3f939ab5d123a53313c0c28fd3ee36575cd2b8b8944af9078828e220a04972d01539c0dde64ad3423abe57528dbb6793daf
7
+ data.tar.gz: 7f57f7b4e110a03538e02a38dadfc49a0837ff15e660576a2fa8fb43ea5185014390e7d27568b3d071728d44bfb4fc250bf55f79a582ef3139259de626d45143
data/Gemfile ADDED
@@ -0,0 +1,31 @@
1
+ source ENV['FLO_GEM_SERVER'] || 'http://artifactory.fkinternal.com/artifactory/v1.0/artifacts/ruby/'
2
+ # Specify your gem's dependencies in turbo_ruby_client_mysql.gemspec
3
+ gemspec
4
+ gem 'rspec', '3.1'
5
+ gem 'json'
6
+ gem 'rack-test'
7
+ gem 'activerecord', "3.2.18", :require => "active_record"
8
+ gem 'rack', '1.3.6'
9
+ gem 'activesupport', "3.2.18", :require => "active_support/all"
10
+ gem 'mysql2', '~> 0.3.10'
11
+ gem 'sc-mq'
12
+
13
+ platforms :jruby do
14
+ gem "jruby-openssl"
15
+ gem 'activerecord-jdbcmysql-adapter'
16
+ end
17
+
18
+
19
+ group :test do
20
+ gem 'simplecov', :require => false, :platform => 'ruby'
21
+ gem 'simplecov-rcov', :require => false ,:platform => 'ruby'
22
+ gem 'simplecov-json', :require => false ,:platform => 'ruby'
23
+ gem 'rake'
24
+ gem 'mocha', :require => false
25
+ #gem 'multitenancy'
26
+ gem 'rack-test', :require => "rack/test"
27
+ gem 'ci_reporter', :require => false
28
+ gem 'sinatra'
29
+ end
30
+
31
+
data/Gemfile.lock ADDED
@@ -0,0 +1,125 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ turbo_client (1.0.3)
5
+
6
+ GEM
7
+ remote: http://artifactory.fkinternal.com/artifactory/v1.0/artifacts/ruby/
8
+ specs:
9
+ activemodel (3.2.18)
10
+ activesupport (= 3.2.18)
11
+ builder (~> 3.0.0)
12
+ activerecord (3.2.18)
13
+ activemodel (= 3.2.18)
14
+ activesupport (= 3.2.18)
15
+ arel (~> 3.0.2)
16
+ tzinfo (~> 0.3.29)
17
+ activesupport (3.2.18)
18
+ i18n (~> 0.6, >= 0.6.4)
19
+ multi_json (~> 1.0)
20
+ arel (3.0.3)
21
+ builder (3.0.4)
22
+ ci_reporter (2.0.0)
23
+ builder (>= 2.1.2)
24
+ concurrent-ruby (1.1.5)
25
+ connection_pool (1.0.0)
26
+ couchbase (1.3.3)
27
+ connection_pool (~> 1.0.0)
28
+ multi_json (~> 1.0)
29
+ yaji (~> 0.3.2)
30
+ dalli (2.1.0)
31
+ diff-lcs (1.2.5)
32
+ docile (1.3.2)
33
+ i18n (0.9.5)
34
+ concurrent-ruby (~> 1.0)
35
+ json (2.1.0)
36
+ metaclass (0.0.4)
37
+ mime-types (1.25.1)
38
+ mocha (1.3.0)
39
+ metaclass (~> 0.0.1)
40
+ multi_json (1.13.1)
41
+ multitenancy (0.0.5)
42
+ mysql2 (0.3.21)
43
+ net-http-persistent (2.9.4)
44
+ netrc (0.7.9)
45
+ rack (1.3.6)
46
+ rack-protection (1.5.3)
47
+ rack
48
+ rack-test (1.1.0)
49
+ rack (>= 1.0, < 3)
50
+ rake (12.3.2)
51
+ rest-client (2.1.0)
52
+ mime-types (>= 1.16)
53
+ net-http-persistent
54
+ netrc (~> 0.7.7)
55
+ rspec (3.1.0)
56
+ rspec-core (~> 3.1.0)
57
+ rspec-expectations (~> 3.1.0)
58
+ rspec-mocks (~> 3.1.0)
59
+ rspec-core (3.1.7)
60
+ rspec-support (~> 3.1.0)
61
+ rspec-expectations (3.1.2)
62
+ diff-lcs (>= 1.2.0, < 2.0)
63
+ rspec-support (~> 3.1.0)
64
+ rspec-mocks (3.1.3)
65
+ rspec-support (~> 3.1.0)
66
+ rspec-support (3.1.2)
67
+ sc-cache (1.0.1)
68
+ couchbase (= 1.3.3)
69
+ dalli (~> 2.1.0)
70
+ sc-mq (1.0.8)
71
+ dalli (~> 2.1.0)
72
+ multitenancy (~> 0.0.4)
73
+ sc-cache (~> 1.0)
74
+ threadpool
75
+ tracer-client (>= 0.0.5)
76
+ uuidtools
77
+ simplecov (0.18.5)
78
+ docile (~> 1.1)
79
+ simplecov-html (~> 0.11)
80
+ simplecov-html (0.12.2)
81
+ simplecov-json (0.2.1)
82
+ json
83
+ simplecov
84
+ simplecov-rcov (0.2.3)
85
+ simplecov (>= 0.4.1)
86
+ sinatra (1.3.3)
87
+ rack (~> 1.3, >= 1.3.6)
88
+ rack-protection (~> 1.2)
89
+ tilt (~> 1.3, >= 1.3.3)
90
+ threadpool (0.1.2)
91
+ tilt (1.3.7)
92
+ tracer-client (0.0.7)
93
+ json (>= 1.7.3)
94
+ rest-client (>= 1.6.7)
95
+ uuidtools (>= 2.1.3)
96
+ tzinfo (0.3.55)
97
+ uuidtools (2.1.5)
98
+ yaji (0.3.5)
99
+
100
+ PLATFORMS
101
+ ruby
102
+
103
+ DEPENDENCIES
104
+ activerecord (= 3.2.18)
105
+ activerecord-jdbcmysql-adapter
106
+ activesupport (= 3.2.18)
107
+ bundler (~> 1.6)
108
+ ci_reporter
109
+ jruby-openssl
110
+ json
111
+ mocha
112
+ mysql2 (~> 0.3.10)
113
+ rack (= 1.3.6)
114
+ rack-test
115
+ rake
116
+ rspec (= 3.1)
117
+ sc-mq
118
+ simplecov
119
+ simplecov-json
120
+ simplecov-rcov
121
+ sinatra
122
+ turbo_client!
123
+
124
+ BUNDLED WITH
125
+ 1.17.2
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ module FixForRakeLastComment
5
+ def last_comment
6
+ last_description
7
+ end
8
+ end
9
+ Rake::Application.send :include, FixForRakeLastComment
10
+
11
+ RSpec::Core::RakeTask.new(:spec)
12
+
13
+ task default: :spec
@@ -0,0 +1,10 @@
1
+ skipMySQLInit: true # mysql connection pool won't be created, use ShippingBackupClient::Client::Config.init_mysql_pool(mysql_config) to initialize pool.
2
+
3
+ # mysql db connection details, you can also provide any additional active record related config
4
+ mysql:
5
+ database : "shipping"
6
+ host : "localhost"
7
+ username : "root"
8
+ password : "pass"
9
+ pool : 20 # [Optional] Default pool size is 50
10
+ reconnect : true # [Optional] Default is true
@@ -0,0 +1,198 @@
1
+ require_relative '../config/shipping_backup_config'
2
+ require_relative '../helpers/shipping_backup_logger'
3
+ require_relative '../models/shipping_backup_dao'
4
+
5
+ module ShippingBackupClient
6
+ module Client
7
+ class ReadClient
8
+ include ShippingBackupClient::Client::Config
9
+
10
+ attr_reader :log
11
+
12
+ def initialize()
13
+ @log = ShippingBackupLogger.new
14
+ end
15
+
16
+ def by_vendor_tracking_id(vendor_tracking_id)
17
+ return_obj = nil
18
+ begin
19
+ return_obj = ShipmentDAO.by_vendor_tracking_id(vendor_tracking_id)
20
+ log.get_shipment_by_vendor_tracking_id(vendor_tracking_id)
21
+ rescue Exception => e
22
+ log.error("Exception occurred while fetch data from ShipmentDAO #{e}")
23
+ raise
24
+ end
25
+ return_obj
26
+ end
27
+
28
+ def by_merchant_reference_id(mer_ref_id)
29
+ return_obj = nil
30
+ begin
31
+ return_obj = ShipmentDAO.by_merchant_ref_id(mer_ref_id)
32
+ log.get_shipment_by_vendor_tracking_id(mer_ref_id)
33
+ rescue Exception => e
34
+ log.error("Exception occurred while fetch data from ShipmentDAO #{e}")
35
+ raise
36
+ end
37
+ return_obj
38
+ end
39
+
40
+ def by_merchant_ref_or_tracking_id(id)
41
+ return_obj = nil
42
+ begin
43
+ shipments = by_merchant_reference_id(id)
44
+ shipments = by_vendor_tracking_id(id) if shipments.empty?
45
+ return_obj = [] if !shipments.empty?
46
+ for shipment in shipments do
47
+ shipment_json = shipment.as_json
48
+ scan_audits = ShipmentScanAuditDAO.where(:shipment_id => shipment.id.to_s, :scanning_type=> "inscan", :status => ['received','received_with_error']).order('id desc').first
49
+ shipment_json["latest_scan_audit"] = scan_audits.as_json unless scan_audits.nil?
50
+ return_obj.push(shipment_json)
51
+ end
52
+
53
+ log.get_shipment_by_vendor_tracking_id(id)
54
+ # latestAudit = ShipmentScanAuditDAO.where(:shipment_id => return_obj.shipment_id, :scanning_type=> "inscan", :status => ['received','received_with_error'])
55
+ rescue Exception => e
56
+ log.error("Exception occurred while fetch data from ShipmentDAO #{e}")
57
+ raise
58
+ end
59
+ return_obj
60
+ end
61
+
62
+ def get_shipment_by_id(id)
63
+ return_obj = nil
64
+ begin
65
+ return_obj = ShipmentDAO.find_by_id(id)
66
+ rescue Exception => e
67
+ log.error("Exception occurred while fetch data from ShipmentDAO #{e}")
68
+ raise
69
+ end
70
+ return_obj
71
+ end
72
+
73
+ def get_shipment_history(id)
74
+ return_obj = nil
75
+ begin
76
+ return_obj = ShipmentStatusHistoryDAO.where(:shipment_id => id).order('id desc').all
77
+ rescue Exception => e
78
+ log.error("Exception occurred while fetch data from ShipmentStatusHistoryDAO #{e}")
79
+ raise
80
+ end
81
+ return_obj
82
+ end
83
+
84
+ def lite_shipments_by_merchant_reference_id(mer_ref_id,is_active=true)
85
+ return_obj = nil
86
+ begin
87
+ return_obj = ShippingLiteShipmentDAO.by_merchant_ref_id(mer_ref_id,is_active)
88
+ rescue Exception => e
89
+ log.error("Exception occurred while fetch data from ShippingLiteShipmentDAO #{e}")
90
+ raise
91
+ end
92
+ return_obj
93
+ end
94
+
95
+ def lite_shipments_by_vendor_tracking_id(vendor_tracking_id,is_active=true)
96
+ return_obj = nil
97
+ begin
98
+ return_obj = ShippingLiteShipmentDAO.by_vendor_track_id(vendor_tracking_id,is_active)
99
+ rescue Exception => e
100
+ log.error("Exception occurred while fetch data from ShippingLiteShipmentDAO #{e}")
101
+ raise
102
+ end
103
+ return_obj
104
+ end
105
+
106
+ def by_merchant_ref_id_or_tracking_id_active(id,is_active=true)
107
+ return_obj = nil
108
+ begin
109
+ return_obj = lite_shipments_by_merchant_reference_id(id,is_active)
110
+ return_obj = lite_shipments_by_vendor_tracking_id(id,is_active) if return_obj.empty?
111
+ rescue Exception => e
112
+ log.error("Exception occurred while fetch data from ShippingLiteShipmentDAO #{e}")
113
+ raise
114
+ end
115
+ return_obj
116
+ end
117
+
118
+ def find_customer_by_id(id)
119
+ return_obj = nil
120
+ begin
121
+ customer = CustomerDAO.where(:id => id).first
122
+ if !customer.nil?
123
+ return_obj = customer.as_json
124
+ return_obj["postal_addresses"] = PostalAddressDAO.where(:owner_id => id).as_json
125
+ return_obj["electronic_addresses"] = ElectronicAddressDAO.where(:owner_id => id).as_json
126
+ return_obj["telecom_numbers"] = TelecomNumberDAO.where(:owner_id => id).as_json
127
+ end
128
+
129
+ rescue Exception => e
130
+ log.error("Exception occurred while fetch data from CustomerDAO #{e}")
131
+ raise
132
+ end
133
+ return_obj
134
+ end
135
+
136
+
137
+ def find_shipment_seller_by_id(id)
138
+ seller = nil
139
+ return_obj = nil
140
+ begin
141
+ shipment = ShipmentDAO.find_by_id(id)
142
+ if !shipment.nil?
143
+ return_seller = ReturnSellerDAO.joins(:shipment_return_seller_mappings).where(:shipment_return_seller_mappings => {:shipment_id => id}).first
144
+ if return_seller.nil?
145
+ seller = SellerDAO.joins(:shipment_seller_mappings).where(:shipment_seller_mappings => {:shipment_id => id}).first
146
+ else
147
+ seller = return_seller
148
+ end
149
+ end
150
+ if !seller.nil?
151
+ seller_id = seller.id
152
+ return_obj = seller.as_json
153
+ return_obj["postal_addresses"] = PostalAddressDAO.where(:owner_id => seller_id).as_json
154
+ return_obj["electronic_addresses"] = ElectronicAddressDAO.where(:owner_id => seller_id).as_json
155
+ return_obj["telecom_numbers"] = TelecomNumberDAO.where(:owner_id => seller_id).as_json
156
+ end
157
+ rescue Exception => e
158
+ log.error("Exception occurred while fetch data from ShipmentDAO #{e}")
159
+ raise
160
+ end
161
+ return_obj
162
+ end
163
+
164
+ def get_lite_shipments_by_vendor_tracking_vendor_id_active(vendor_tracking_id, vendor_id,is_active=true)
165
+ return_obj = nil
166
+ begin
167
+ return_obj = ShippingLiteShipmentDAO.where(vendor_tracking_id: vendor_tracking_id,vendor_id: vendor_id ,active: is_active)
168
+ rescue Exception => e
169
+ log.error("Exception occurred while fetch data from ShippingLiteShipmentDAO #{e}")
170
+ raise
171
+ end
172
+ return_obj
173
+ end
174
+
175
+ def get_history_by_id(id)
176
+ return_obj = nil
177
+ begin
178
+ return_obj = ShipmentStatusHistoryDAO.find_by_id(id)
179
+ rescue Exception => e
180
+ log.error("Exception occurred while fetch data from ShipmentStatusHistoryDAO #{e.message}")
181
+ raise
182
+ end
183
+ return_obj
184
+ end
185
+
186
+ def get_shipment_note_by_history_id(id,types)
187
+ return_obj = nil
188
+ begin
189
+ return_obj = ShipmentNoteDAO.where(:shipment_status_history_id => id,:note_type => types.split(","))
190
+ rescue Exception => e
191
+ log.error("Exception occurred while fetch data from ShipmentNoteDAO #{e.message}")
192
+ raise
193
+ end
194
+ return_obj
195
+ end
196
+ end
197
+ end
198
+ end
@@ -0,0 +1,63 @@
1
+ require_relative "../db/shipping_backup_db"
2
+ require_relative "../helpers/shipping_backup_logger"
3
+
4
+
5
+ module ShippingBackupClient
6
+ module Client
7
+ module Config
8
+
9
+ @@log = ShippingBackupLogger.new
10
+ @@config_file = ENV['SHIPPING_BACKUP_CONFIG'] || '/etc/flo/shipping_backup_config.yml'
11
+ @@queue_cluster_mappings = {}
12
+ @@strategy = nil
13
+
14
+
15
+ begin
16
+ @@config = HashWithIndifferentAccess.new (YAML::load_file @@config_file)
17
+ rescue Exception => e
18
+ @@config = {}
19
+ @@log.error("Error while loading shipping_backup configuration #{e} from #{@@config_file}")
20
+ raise
21
+ end
22
+ @@log.debug("loaded yaml config #{@@config}")
23
+
24
+
25
+ skip_mysql_init_enabled = @@config[:skipMySQLInit] ? (@@config[:skipMySQLInit].to_s == 'true') : false
26
+
27
+ if skip_mysql_init_enabled
28
+ @@log.warn("skip mysql init enabled.. you must init connection pool using init_mysql_pool(mysql_config)")
29
+ else
30
+ ShippingBackupClient::Client::DBConfig.connect_shipping_backup_db(@@config[:mysql])
31
+ end
32
+
33
+
34
+ def getDecriptedValue(data)
35
+ grant_type = @@config[:cryptex][:grant_type]
36
+ client_id = @@config[:cryptex][:client_id]
37
+ client_secret = @@config[:cryptex][:client_secret]
38
+ client_secret = CGI.escape(client_secret)
39
+ target_client_id = @@config[:cryptex][:target_client_id]
40
+ auth_url = @@config[:cryptex][:auth_url]
41
+ cryptex_url = @@config[:cryptex][:cryptex_url]
42
+ if !$cache_on_master_worker.nil? && !$cache_on_master_worker[data].nil? && !$cache_on_master_worker[data].empty?
43
+ cryptex_result = $cache_on_master_worker[data]
44
+ logger.debug("Got decrypted backup_client password from cache #{cryptex_result}")
45
+ return cryptex_result.strip()
46
+ end
47
+ cryptex_result = `bash /etc/cryptex-client/cryptex_helper.sh #{grant_type} #{client_id} #{client_secret} #{target_client_id} #{data} #{auth_url} #{cryptex_url}`
48
+ return cryptex_result.strip()
49
+ end
50
+
51
+ def get_mysql_config
52
+ password = getDecriptedValue(@@config[:mysql][:password])
53
+ @@config[:mysql][:password] = password
54
+ @@config[:mysql]
55
+ end
56
+
57
+ def init_mysql_pool(mysql_config)
58
+ @@log.debug("mysql pool init with config.. #{mysql_config}")
59
+ ShippingBackupClient::Client::DBConfig.connect_shipping_backup_db(mysql_config)
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,60 @@
1
+ require_relative '../models/shipping_backup_dao'
2
+ require_relative '../models/customer_backup_dao'
3
+ require_relative '../models/shipping_lite_backup_dao'
4
+ require_relative '../models/return_seller_backup_dao'
5
+ require_relative '../models/shipment_return_seller_mappings_dao'
6
+ require_relative '../models/seller_backup_dao'
7
+ require_relative '../models/shipment_seller_mapping_dao'
8
+ require_relative '../models/postal_address_dao'
9
+ require_relative '../models/electronic_address_dao'
10
+ require_relative '../models/telecom_numbers_dao'
11
+ require_relative '../models/shipment_status_history_dao'
12
+ require_relative '../models/shipment_scan_audit_dao'
13
+ require_relative '../models/shipment_note_dao'
14
+
15
+ module ShippingBackupClient
16
+ module Client
17
+ module DBConfig
18
+
19
+ DB_DEFAULTS = {
20
+ 'adapter' => 'mysql2',
21
+ 'reconnect' => true,
22
+ 'pool' => 50
23
+ }
24
+ def self.connect_shipping_backup_db(mysql_config)
25
+ # Setup our logger
26
+ ActiveRecord::Base.logger = $logger
27
+
28
+ # Include Active Record class name as root for JSON serialized output.
29
+ ActiveRecord::Base.include_root_in_json = false
30
+
31
+ # Store the full class name (including module namespace) in STI type column.
32
+ ActiveRecord::Base.store_full_sti_class = true
33
+
34
+ # Use ISO 8601 format for JSON serialized times and dates.
35
+ ActiveSupport.use_standard_json_time_format = true
36
+
37
+ # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
38
+ # if you're including raw json in an HTML page.
39
+ ActiveSupport.escape_html_entities_in_json = false
40
+
41
+ # Now we can establish connection with our db
42
+ $logger.info("connecting to shipping_backup db using config : #{DB_DEFAULTS.merge(mysql_config).merge({'password' => '*******'})}") rescue nil
43
+ ShipmentDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
44
+ CustomerDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
45
+ ShippingLiteShipmentDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
46
+ ShipmentSellerMappingDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
47
+ SellerDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
48
+ ReturnSellerDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
49
+ ShipmentReturnSellerMappingsDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
50
+ PostalAddressDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
51
+ ElectronicAddressDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
52
+ TelecomNumberDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
53
+ ShipmentStatusHistoryDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
54
+ ShipmentScanAuditDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
55
+ ShipmentNoteDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
56
+ end
57
+ end
58
+ end
59
+ end
60
+
@@ -0,0 +1,32 @@
1
+ require 'logger'
2
+
3
+ class ShippingBackupLogger
4
+ attr_reader :log
5
+
6
+ def initialize(log = nil)
7
+ @log = log ||
8
+ ($logger rescue nil) || # use a global logger if available
9
+ (logger rescue nil) || # use logger if available
10
+ Logger.new(STDOUT)
11
+ end
12
+
13
+ def get_shipment_by_vendor_tracking_id(vendor_tracking_id)
14
+ log.info "shipping backup client: Fetched shipment for vendor_tracking_id : #{vendor_tracking_id}"
15
+ end
16
+
17
+ def warn(data)
18
+ log.warn(data)
19
+ end
20
+
21
+ def error(data)
22
+ log.error(data)
23
+ end
24
+
25
+ def info(data)
26
+ log.info(data)
27
+ end
28
+
29
+ def debug(data)
30
+ log.debug(data)
31
+ end
32
+ end
@@ -0,0 +1,25 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: customers
4
+ #
5
+ # id :integer not null, primary key
6
+ # created_at :datetime
7
+ # updated_at :datetime
8
+ #
9
+
10
+ class CustomerDAO < ActiveRecord::Base
11
+ self.table_name = "customers"
12
+ #include Fkl::Contactable::ContactMechanisms
13
+ has_many :postal_addresses,:class_name => "PostalAddressDAO", :dependent => :destroy, :as => :owner, :foreign_key => :owner_id
14
+ has_many :telecom_numbers, :class_name => "TelecomAddressDAO", :dependent => :destroy, :as => :owner
15
+ has_many :electronic_addresses, :class_name => "ElectronicAddressDAO",:dependent => :destroy, :as => :owner
16
+
17
+ def self.matching_customer_id(id)
18
+ CustomerDAO.find_by_id(id)
19
+ end
20
+
21
+ def postal_address
22
+ self.postal_addresses.enabled.last
23
+ end
24
+
25
+ end
@@ -0,0 +1,11 @@
1
+ class ElectronicAddressDAO < ActiveRecord::Base
2
+ self.table_name = "electronic_addresses"
3
+ belongs_to :owner, :polymorphic => true
4
+
5
+ # def self.build_electronic_address_from_hash(shipment_hash_obj)
6
+ # electronic_address = ElectronicAddressDAO.new
7
+ # electronic_address.electronic_address_type = shipment_hash_obj[:electronic_address_type] || 'Primary'
8
+ # electronic_address.info_string = shipment_hash_obj[:info_string] || shipment_hash_obj[:email_id]
9
+ # electronic_address
10
+ # end
11
+ end
@@ -0,0 +1,11 @@
1
+ class PostalAddressDAO < ActiveRecord::Base
2
+
3
+ self.table_name = "postal_addresses"
4
+
5
+ belongs_to :owner, :polymorphic => true
6
+
7
+ def self.enabled
8
+ PostalAddressDAO.where(:enabled=>true)
9
+ end
10
+
11
+ end
@@ -0,0 +1,19 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: return_seller
4
+ #
5
+ # id :integer not null, primary key
6
+ # created_at :datetime
7
+ # updated_at :datetime
8
+ #
9
+ class ReturnSellerDAO < ActiveRecord::Base
10
+
11
+ self.table_name = "return_sellers"
12
+
13
+ has_many :postal_addresses, :dependent => :destroy, :as => :owner
14
+ has_many :telecom_numbers, :dependent => :destroy, :as => :owner
15
+ has_many :electronic_addresses, :dependent => :destroy, :as => :owner
16
+ has_one :shipment_return_seller_mappings, :class_name => 'ShipmentReturnSellerMappingsDAO', :foreign_key => :return_seller_id
17
+ has_one :shipment, :through => :shipment_return_seller_mappings, :source => :shipment
18
+
19
+ end
@@ -0,0 +1,24 @@
1
+ # == Schema Information
2
+ #
3
+ # Table name: sellers
4
+ #
5
+ # id :integer not null, primary key
6
+ # seller_reference_id :string(255)
7
+ # created_at :datetime
8
+ # updated_at :datetime
9
+ # tin_number :string(255)
10
+ # vat_number :string(255)
11
+ # cst_number :string(255)
12
+ #
13
+
14
+ class SellerDAO < ActiveRecord::Base
15
+
16
+ self.table_name = "sellers"
17
+
18
+ has_many :postal_addresses, :dependent => :destroy, :as => :owner
19
+ has_many :telecom_numbers, :dependent => :destroy, :as => :owner
20
+ has_many :electronic_addresses, :dependent => :destroy, :as => :owner
21
+ has_one :shipment_seller_mappings, :class_name => 'ShipmentSellerMappingDAO' , :foreign_key => :seller_id
22
+ has_one :shipment,:through => :shipment_seller_mapping, :source => :shipment
23
+
24
+ end