Class: Centaman::Object::Member

Inherits:
Centaman::Object show all
Defined in:
lib/centaman/object/member.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Centaman::Object

#after_init, #initialize

Constructor Details

This class inherits a constructor from Centaman::Object

Instance Attribute Details

#addressObject (readonly)

rubocop:disable Metrics/MethodLength



4
5
6
# File 'lib/centaman/object/member.rb', line 4

def address
  @address
end

#idObject (readonly)

rubocop:disable Metrics/MethodLength



4
5
6
# File 'lib/centaman/object/member.rb', line 4

def id
  @id
end

#membershipsObject (readonly)

rubocop:disable Metrics/MethodLength



4
5
6
# File 'lib/centaman/object/member.rb', line 4

def memberships
  @memberships
end

#package_idObject (readonly)

rubocop:disable Metrics/MethodLength



4
5
6
# File 'lib/centaman/object/member.rb', line 4

def package_id
  @package_id
end

#phoneObject (readonly)

rubocop:disable Metrics/MethodLength



4
5
6
# File 'lib/centaman/object/member.rb', line 4

def phone
  @phone
end

Instance Method Details

#attributesObject



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/centaman/object/member.rb', line 83

def attributes
  [
    Centaman::Attribute.new(
      centaman_key: 'MemberCode',
      app_key: :member_code,
      type: :integer
    ),
    Centaman::Attribute.new(
      centaman_key: 'MemberNumber',
      app_key: :member_number,
      type: :string
    ),
    Centaman::Attribute.new(
      centaman_key: 'Memberships',
      app_key: :membership_list,
      type: :string
    ),
    Centaman::Attribute.new(
      centaman_key: 'FirstName',
      app_key: :first_name,
      type: :string
    ),
    Centaman::Attribute.new(
      centaman_key: 'LastName',
      app_key: :last_name,
      type: :string
    ),
    Centaman::Attribute.new(
      centaman_key: 'Title',
      app_key: :title,
      type: :string
    ),
    Centaman::Attribute.new(
      centaman_key: 'Email',
      app_key: :email,
      type: :string
    ),
    Centaman::Attribute.new(
      centaman_key: 'Password',
      app_key: :password,
      type: :string
    ),
    Centaman::Attribute.new(
      centaman_key: 'Gender',
      app_key: :gender,
      type: :string
    ),
    Centaman::Attribute.new(
      centaman_key: 'DateOfBirth',
      app_key: :date_of_birth,
      type: :datetime
    ),
    Centaman::Attribute.new(
      centaman_key: 'HomeAddress',
      app_key: :home_address,
      type: :string
    ),
    Centaman::Attribute.new(
      centaman_key: 'IsPrimary',
      app_key: :is_primary,
      type: :boolean
    ),
    Centaman::Attribute.new(
      centaman_key: 'PrimaryMemberId',
      app_key: :primary_member_id,
      type: :integer
    ),
    Centaman::Attribute.new(
      centaman_key: 'GiftPurchaserId',
      app_key: :gift_purchaser_id,
      type: :integer
    ),
    Centaman::Attribute.new(
      centaman_key: 'ConcessionCardNumber',
      app_key: :concession_card_number,
      type: :integer
    ),
    Centaman::Attribute.new(
      centaman_key: 'Incomplete',
      app_key: :incomplete,
      type: :boolean
    ),
    Centaman::Attribute.new(
      centaman_key: 'MemberPhoto',
      app_key: :member_photo,
      type: :string
    )
  ]
end

#define_variables(args) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/centaman/object/member.rb', line 6

def define_variables(args)
  super
  @id = member_code
  @address = set_address
  @phone = @address ? @address[:phone] : nil
  @memberships = set_memberships
end

#full_nameObject



14
15
16
# File 'lib/centaman/object/member.rb', line 14

def full_name
  [first_name, last_name].join(' ')
end

#jsonObject



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/centaman/object/member.rb', line 60

def json
  {
    id: id,
    member_code: member_code,
    member_number: member_number,
    first_name: first_name,
    last_name: last_name,
    full_name: full_name,
    title: title,
    email: email,
    gender: gender,
    date_of_birth: date_of_birth,
    address: address,
    is_primary: is_primary,
    primary_member_id: primary_member_id,
    gift_purchaser_id: gift_purchaser_id,
    concession_card_number: concession_card_number,
    incomplete: incomplete,
    member_photo: member_photo,
    memberships: memberships
  }
end

#set_addressObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/centaman/object/member.rb', line 18

def set_address
  return unless home_address
  {
    street_address: home_address['Street1'],
    street_address_two: home_address['Street2'],
    suburb: home_address['Suburb'],
    state: home_address['State'],
    zip: home_address['Postcode'],
    city: home_address['City'],
    country: home_address['Country'],
    phone: home_address['HomePhone'],
    work_phone: home_address['WorkPhone'],
    mobile_phone: home_address['MobilePhone']
  }
end

#set_membership(membership) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/centaman/object/member.rb', line 39

def set_membership(membership)
  {
    linkfield: membership['Linkfield'],
    type_name: membership['TypeName'],
    cancelled: membership['Cancelled'],
    activated: membership['Activated'],
    unique_package_id: membership['UniquePackageId'],
    member_code: membership['MemberCode'],
    type_code: membership['TypeCode'],
    cost: membership['Cost'],
    tax: membership['Tax'],
    paid: membership['Paid'],
    join_date: membership['JoinDate'],
    expiry_date: membership['ExpiryDate'],
    is_gift: membership['IsGift'],
    purchaser_renewal: membership['PurchaserRenewal'],
    package_id: membership['PackageID'],
    payment_gateway_reference: membership['PaymentGatewayReference']
  }
end

#set_membershipsObject



34
35
36
37
# File 'lib/centaman/object/member.rb', line 34

def set_memberships
  return [] unless membership_list && membership_list.any?
  membership_list.map { |m| set_membership(m) }
end