centaman 7.0.3 → 7.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccfc2bd51d519c83f9eb9294bb96c7117c48b9c321d50e1e7728fc0da93fc5bb
4
- data.tar.gz: 4e4a22ec3eb65255cee0537c92bf43f229abb6e5ee91b7dbaa6fcc85acec1a8c
3
+ metadata.gz: 95695fa209e9b2007496923bdf9b79120eb581cece4ecefeba24b9aa453e256d
4
+ data.tar.gz: 60a034478c83da0c6bdde10b417bf61f644673a8802e021cb2da211b0cf1fd18
5
5
  SHA512:
6
- metadata.gz: 07e5856bd63c377d3dc3777c050c069a264fdd91a00ee03138ebb7008a952f520256997193186536edf56bb4dc28b4a137f412fa521c52295aeddc6e8976d4b1
7
- data.tar.gz: b07e5178cc87590f6e3c7c986df3dae40d298d661b8c304a6e41ba8e4e2742cf6491d19366b2e0b2408cf1584d52310aee390bd30bd33485de46789cdc4b5d06
6
+ metadata.gz: 9a7bd5b836fc2a724e2c3dadd22c4eaeec47d6d59b71efdc4c863f439d1976a6559a430b3bc142c89507ff9bd804b0844256b0ed7cdf75fd4819a48fcde6c7f4
7
+ data.tar.gz: 612b40adb9230eddfc18ab72d24e6421e3ffecd0e47e65d8187b6e10c7d64a048c4ade2f8cbf058a59e8f6dda233a71b3a6e0466aaaef40341a16028b844f114
@@ -28,7 +28,7 @@ module Centaman
28
28
  end
29
29
 
30
30
  def final_object_class
31
- name = self.class.name.split('::').last
31
+ name = object_class.name.split('::').last
32
32
  override = Centaman.configuration.object_overrides[name]
33
33
  override_class = override.constantize if override
34
34
  override_class || object_class
@@ -0,0 +1,76 @@
1
+ require 'securerandom'
2
+
3
+ module Centaman
4
+ class Service::CreatePrimaryMember < Centaman::Service
5
+ include Centaman::JsonWrapper
6
+
7
+ attr_reader :first_name, :last_name, :address, :gender, :title,
8
+ :date_of_birth, :email, :password, :phone, :is_primary
9
+
10
+ def after_init(args)
11
+ @first_name = args[:first_name].try(:squish)
12
+ @last_name = args[:last_name].try(:squish)
13
+ @address = args[:address].try(:symbolize_keys)
14
+ @gender = args[:gender].try(:squish)
15
+ @title = args[:title].try(:squish)
16
+ @date_of_birth = args[:date_of_birth]
17
+ @email = args[:email].try(:squish)
18
+ @phone = args[:phone]
19
+ @is_primary = args[:is_primary] || false
20
+ @password = args[:password] || SecureRandom.hex
21
+ end
22
+
23
+ def endpoint
24
+ '/member_services/Member'
25
+ end
26
+
27
+ def object_class
28
+ Centaman::Object::Member
29
+ end
30
+
31
+ def build_object(resp)
32
+ return build_objects(resp) if resp.respond_to?(:map)
33
+ return create_error(resp) unless resp.respond_to?(:merge)
34
+ @build_object ||= object_class.new(resp.merge(additional_hash_to_serialize_after_response))
35
+ end
36
+
37
+ def options_hash
38
+ [
39
+ {
40
+ 'FirstName' => first_name.try(:upcase),
41
+ 'LastName' => last_name.try(:upcase),
42
+ 'HomeAddress' => home_address,
43
+ 'Gender' => gender,
44
+ 'Title' => title.try(:upcase),
45
+ 'DateOfBirth' => date_of_birth,
46
+ 'Email' => email.try(:upcase),
47
+ 'Password' => password,
48
+ 'IsPrimary' => is_primary
49
+ }
50
+ ].to_json
51
+ end
52
+
53
+ def home_address
54
+ return if !address
55
+ {
56
+ 'street1': address[:street_address].try(:squish).try(:upcase),
57
+ 'street2': address[:street_address_two].try(:squish).try(:upcase),
58
+ 'suburb': address[:suburb].try(:squish).try(:upcase),
59
+ 'city': address[:city].try(:squish).try(:upcase),
60
+ 'state': address[:state].try(:squish).try(:upcase),
61
+ 'postcode': address[:zip].try(:squish).try(:upcase),
62
+ 'country': address[:country].try(:squish).try(:upcase),
63
+ 'homePhone': phone.try(:delete, "^0-9"),
64
+ 'workPhone': address[:work_phone].try(:delete, "^0-9"),
65
+ 'mobilePhone': address[:mobile_phone].try(:delete, "^0-9")
66
+ }
67
+ end
68
+
69
+ private
70
+
71
+ def create_error(resp)
72
+ message = resp.parsed_response || 'Unable to create primary member record.'
73
+ raise Centaman::Exceptions::CentamanError.new(message)
74
+ end
75
+ end
76
+ end
@@ -1,3 +1,3 @@
1
1
  module Centaman
2
- VERSION = "7.0.3"
2
+ VERSION = "7.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: centaman
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.3
4
+ version: 7.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - francirp
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-11-13 00:00:00.000000000 Z
12
+ date: 2018-11-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -121,6 +121,7 @@ files:
121
121
  - lib/centaman/service/cost_rate.rb
122
122
  - lib/centaman/service/coupon_check.rb
123
123
  - lib/centaman/service/create_customer.rb
124
+ - lib/centaman/service/create_member.rb
124
125
  - lib/centaman/service/create_primary_member.rb
125
126
  - lib/centaman/service/create_retail_customer.rb
126
127
  - lib/centaman/service/create_secondary_members.rb