Class: Workarea::GlobalE::Api::SendOrderToMerchant::SaveUser

Inherits:
Object
  • Object
show all
Defined in:
app/services/workarea/global_e/api/send_order_to_merchant/save_user.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_id, shipping_details:, billing_details:, culture_code:) ⇒ SaveUser

Returns a new instance of SaveUser.

Parameters:



21
22
23
24
25
26
# File 'app/services/workarea/global_e/api/send_order_to_merchant/save_user.rb', line 21

def initialize(user_id, shipping_details:, billing_details:, culture_code:)
  @user_id = user_id
  @shipping_details = shipping_details
  @billing_details = billing_details
  @culture_code = culture_code
end

Instance Attribute Details

#billing_detailsObject (readonly)

Returns the value of attribute billing_details.



5
6
7
# File 'app/services/workarea/global_e/api/send_order_to_merchant/save_user.rb', line 5

def billing_details
  @billing_details
end

#culture_codeObject (readonly)

Returns the value of attribute culture_code.



5
6
7
# File 'app/services/workarea/global_e/api/send_order_to_merchant/save_user.rb', line 5

def culture_code
  @culture_code
end

#shipping_detailsObject (readonly)

Returns the value of attribute shipping_details.



5
6
7
# File 'app/services/workarea/global_e/api/send_order_to_merchant/save_user.rb', line 5

def shipping_details
  @shipping_details
end

#user_idObject (readonly)

Returns the value of attribute user_id.



5
6
7
# File 'app/services/workarea/global_e/api/send_order_to_merchant/save_user.rb', line 5

def user_id
  @user_id
end

Class Method Details

.perform!(user_id, shipping_details:, billing_details:, culture_code:) ⇒ Object



7
8
9
10
11
12
13
14
# File 'app/services/workarea/global_e/api/send_order_to_merchant/save_user.rb', line 7

def self.perform!(user_id, shipping_details:, billing_details:, culture_code:)
  new(
    user_id,
    shipping_details: shipping_details,
    billing_details: billing_details,
    culture_code: culture_code
  ).perform!
end

Instance Method Details

#perform!Object



28
29
30
31
32
33
34
35
# File 'app/services/workarea/global_e/api/send_order_to_merchant/save_user.rb', line 28

def perform!
  return if user.nil?
  upsert_address(shipping_details)
  upsert_address(billing_details)
  user.global_e_culture_code = culture_code

  user.save
end