centaman 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/centaman.rb +1 -0
- data/lib/centaman/object/add_on.rb +2 -1
- data/lib/centaman/service.rb +4 -3
- data/lib/centaman/service/add_on.rb +1 -1
- data/lib/centaman/service/authenticate_member.rb +0 -2
- data/lib/centaman/service/create_udf.rb +28 -0
- data/lib/centaman/service/purchase_membership.rb +28 -4
- data/lib/centaman/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 340746dbed78a24b56cbb1a3acf9a769c365befb5d112604ed40ad51c801d595
|
4
|
+
data.tar.gz: b0e7e8b4ff3414d7d1155691ea3b1a0f2d1d1d6457667c6dccdcfb62969d142d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 890b6c0e6e2b54ace0b3c97181a2c38c1d740e0b4e96de0b072f090d7b045d5ede2864dea63fa625ebc2c70f2f5bc1ff27d51419bb276b97d5de0bbd4124828c
|
7
|
+
data.tar.gz: 9fbedb8fa1f34cd4e88d4b0934a88d4f593e6cbcda0d537847c87b08ff790f0c1c889e007a900827bf49e40bbea30c232b4b5ad8a79f9c0b6afc08e8bd1a8cc4
|
data/lib/centaman.rb
CHANGED
@@ -16,6 +16,7 @@ require 'centaman/service/coupon_check'
|
|
16
16
|
require 'centaman/service/create_customer'
|
17
17
|
require 'centaman/service/create_primary_member'
|
18
18
|
require 'centaman/service/create_secondary_member'
|
19
|
+
require 'centaman/service/create_udf'
|
19
20
|
require 'centaman/service/extra'
|
20
21
|
require 'centaman/service/gift_ticket'
|
21
22
|
require 'centaman/service/general_admission_ticket'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
module Centaman
|
2
2
|
class Object::AddOn < Centaman::Object
|
3
|
-
attr_reader :id, :membership_type_id
|
3
|
+
attr_reader :id, :membership_type_id
|
4
4
|
|
5
5
|
def define_variables(args)
|
6
6
|
super
|
@@ -15,6 +15,7 @@ module Centaman
|
|
15
15
|
membership_code: membership_code,
|
16
16
|
membership_class: membership_class,
|
17
17
|
cost: cost,
|
18
|
+
pay_price: pay_price,
|
18
19
|
minimum_age: minimum_age,
|
19
20
|
maximum_age: maximum_age,
|
20
21
|
membership_description: membership_description,
|
data/lib/centaman/service.rb
CHANGED
@@ -3,7 +3,7 @@ require 'timeout'
|
|
3
3
|
module Centaman
|
4
4
|
#:nodoc:
|
5
5
|
class Service < Wrapper
|
6
|
-
DEFAULT_TIMEOUT_TIME =
|
6
|
+
DEFAULT_TIMEOUT_TIME = 20
|
7
7
|
|
8
8
|
def after_init(args)
|
9
9
|
# overwritten by subclasses
|
@@ -17,6 +17,7 @@ module Centaman
|
|
17
17
|
proc.call
|
18
18
|
end
|
19
19
|
rescue Timeout::Error
|
20
|
+
p "*** CENTAMAN GEM TIMEOUT ***"
|
20
21
|
raise Exceptions::CentamanTimeout
|
21
22
|
end
|
22
23
|
resp
|
@@ -29,8 +30,8 @@ module Centaman
|
|
29
30
|
end
|
30
31
|
resp = wrap_request_in_case_of_timeout(req, timeout_time: 20)
|
31
32
|
|
32
|
-
raise resp['Message'] if resp.is_a?(Hash)
|
33
|
-
raise Exceptions::CentamanTimeout unless resp.success?
|
33
|
+
raise resp['Message'] if resp && resp.is_a?(Hash)
|
34
|
+
raise Exceptions::CentamanTimeout unless resp && resp.success?
|
34
35
|
resp
|
35
36
|
end
|
36
37
|
end
|
@@ -18,7 +18,7 @@ module Centaman
|
|
18
18
|
|
19
19
|
def self.find(membership_type_id, id)
|
20
20
|
obj = new(membership_type_id: membership_type_id)
|
21
|
-
obj.objects.detect {|obj| obj.id == id }
|
21
|
+
obj.objects.detect { |obj| obj.id == id }
|
22
22
|
end
|
23
23
|
|
24
24
|
def additional_hash_to_serialize_after_response
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Centaman
|
2
|
+
class Service::CreateUdf < Centaman::Service
|
3
|
+
attr_reader :udfs, :member_code
|
4
|
+
|
5
|
+
def after_init(args)
|
6
|
+
@udfs = args.fetch(:udfs, [])
|
7
|
+
@member_code = args[:member_code]
|
8
|
+
end
|
9
|
+
|
10
|
+
def endpoint
|
11
|
+
"/udf_services/UDFMember?memberCode=#{member_code}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def build_udf_body(udf)
|
15
|
+
{
|
16
|
+
'Value': udf.value,
|
17
|
+
'FieldName': udf.field_name,
|
18
|
+
'FieldType': udf.field_type,
|
19
|
+
'FieldLength': udf.field_length,
|
20
|
+
'TabName': udf.tab_name,
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def options_hash
|
25
|
+
udfs.map { |udf| build_udf_body(udf) }.to_json
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -1,19 +1,21 @@
|
|
1
1
|
module Centaman
|
2
2
|
class Service::PurchaseMembership < Centaman::Service
|
3
|
-
attr_reader :payment_reference, :order_info, :checkout_service,
|
3
|
+
attr_reader :payment_reference, :order_info, :checkout_service, :coupon_service,
|
4
4
|
:members, :memberships, :add_ons, :membership_type_id,
|
5
|
-
:is_new, :purchaser_renewal
|
5
|
+
:is_new, :purchaser_renewal, :coupon
|
6
6
|
|
7
7
|
def after_init(args)
|
8
8
|
@payment_reference = args[:payment_reference]
|
9
|
-
@is_new =
|
9
|
+
@is_new = true
|
10
10
|
@order_info = args[:order_info]
|
11
11
|
@purchaser_renewal = order_info.is_renewal
|
12
12
|
@checkout_service = args[:checkout_service]
|
13
|
+
@coupon_service = args[:coupon_service]
|
13
14
|
@membership_type_id = @order_info.membership_type_id
|
14
15
|
@members = @order_info.members
|
15
16
|
@add_ons = @checkout_service.add_ons
|
16
17
|
@memberships = []
|
18
|
+
@coupon = @coupon_service.valid_coupon
|
17
19
|
build_membership_request
|
18
20
|
end
|
19
21
|
|
@@ -22,7 +24,7 @@ module Centaman
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def membership_payload(member_id, add_on)
|
25
|
-
{
|
27
|
+
payload = {
|
26
28
|
'MemberCode': member_id,
|
27
29
|
'TypeCode': add_on.id,
|
28
30
|
'Cost': add_on.cost,
|
@@ -31,6 +33,28 @@ module Centaman
|
|
31
33
|
'PackageID': membership_type_id,
|
32
34
|
'PurchaserRenewal': purchaser_renewal
|
33
35
|
}
|
36
|
+
coupon.present? ? payload.merge(coupon_args(add_on)) : payload
|
37
|
+
end
|
38
|
+
|
39
|
+
def coupon_args(add_on)
|
40
|
+
return empty_coupon_args unless coupon_service.coupon_applies(add_on)
|
41
|
+
{
|
42
|
+
'Coupon': {
|
43
|
+
"CouponCode": coupon.code,
|
44
|
+
"DiscountAmount": coupon_service.amount_saved(add_on),
|
45
|
+
"StockID": coupon.stock_code
|
46
|
+
}
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def empty_coupon_args
|
51
|
+
{
|
52
|
+
'Coupon': {
|
53
|
+
"CouponCode": nil,
|
54
|
+
"DiscountAmount": 0,
|
55
|
+
"StockID": nil
|
56
|
+
}
|
57
|
+
}
|
34
58
|
end
|
35
59
|
|
36
60
|
def build_membership_request
|
data/lib/centaman/version.rb
CHANGED
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: 3.
|
4
|
+
version: 3.1.0
|
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-03-
|
12
|
+
date: 2018-03-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/centaman/service/create_customer.rb
|
117
117
|
- lib/centaman/service/create_primary_member.rb
|
118
118
|
- lib/centaman/service/create_secondary_member.rb
|
119
|
+
- lib/centaman/service/create_udf.rb
|
119
120
|
- lib/centaman/service/extra.rb
|
120
121
|
- lib/centaman/service/general_admission_ticket.rb
|
121
122
|
- lib/centaman/service/gift_ticket.rb
|