Class: Atrium::Member

Inherits:
Object
  • Object
show all
Extended by:
Pageable
Includes:
ActiveAttr::Model
Defined in:
lib/atrium/member.rb

Constant Summary

Constants included from Pageable

Pageable::DEFAULT_RECORDS_PER_PAGE

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Pageable

make_get_request, paginate, paginate_each, paginate_in_batches, pagination_info

Class Method Details

._member_pagination_options(options) ⇒ Object



163
164
165
166
167
# File 'lib/atrium/member.rb', line 163

def self._member_pagination_options(options)
  user_guid = options.fetch(:user_guid)
  endpoint = "/users/#{user_guid}/members"
  options.merge(:endpoint => endpoint, :resource => "members")
end

.create(user_guid:, institution_code:, credentials:) ⇒ Object

CLASS METHODS



19
20
21
22
23
24
25
26
# File 'lib/atrium/member.rb', line 19

def self.create(user_guid:, institution_code:, credentials:)
  endpoint = "/users/#{user_guid}/members"
  body = create_params(institution_code, credentials)
  member_response = ::Atrium.client.make_request(:post, endpoint, body)

  member_params = member_response["member"]
  ::Atrium::Member.new(member_params)
end

.list(options = {}) ⇒ Object



28
29
30
31
# File 'lib/atrium/member.rb', line 28

def self.list(options = {})
  options = _member_pagination_options(options)
  paginate(options)
end

.list_each(options = {}) ⇒ Object



33
34
35
36
# File 'lib/atrium/member.rb', line 33

def self.list_each(options = {})
  options = _member_pagination_options(options)
  paginate_each(options) { |member| yield member }
end

.list_in_batches(options = {}) ⇒ Object



38
39
40
41
# File 'lib/atrium/member.rb', line 38

def self.list_in_batches(options = {})
  options = _member_pagination_options(options)
  paginate_in_batches(options) { |batch| yield batch }
end

.read(user_guid:, member_guid:) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/atrium/member.rb', line 43

def self.read(user_guid:, member_guid:)
  endpoint = "/users/#{user_guid}/members/#{member_guid}"
  member_response = ::Atrium.client.make_request(:get, endpoint)

  member_params = member_response["member"]
  ::Atrium::Member.new(member_params)
end

Instance Method Details

#accounts(options = {}) ⇒ Object

INSTANCE METHODS



54
55
56
57
# File 'lib/atrium/member.rb', line 54

def accounts(options = {})
  options = (options)
  self.class.paginate(options)
end

#accounts_in_batches(options = {}) ⇒ Object



64
65
66
67
# File 'lib/atrium/member.rb', line 64

def accounts_in_batches(options = {})
  options = (options)
  self.class.paginate_in_batches(options) { |batch| yield batch }
end

#aggregateObject



69
70
71
72
73
74
75
76
# File 'lib/atrium/member.rb', line 69

def aggregate
  endpoint = "/users/#{user_guid}/members/#{guid}/aggregate"
  member_response = ::Atrium.client.make_request(:post, endpoint)

  member_params = member_response["member"]
  assign_attributes(member_params)
  self
end

#aggregation_statusObject



78
79
80
81
82
83
84
85
# File 'lib/atrium/member.rb', line 78

def aggregation_status
  endpoint = "/users/#{user_guid}/members/#{guid}/status"
  member_response = ::Atrium.client.make_request(:get, endpoint)

  member_params = member_response["member"]
  assign_attributes(member_params)
  self
end

#challengesObject



87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/atrium/member.rb', line 87

def challenges
  endpoint = "/users/#{user_guid}/members/#{guid}/challenges"
  challenge_response = ::Atrium.client.make_request(:get, endpoint)

  return nil if challenge_response.nil?

  challenge_params = challenge_response["challenges"]

  challenge_params.map do |challenge|
    ::Atrium::Challenge.new(challenge)
  end
end

#credentialsObject



135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/atrium/member.rb', line 135

def credentials
  endpoint = "/users/#{user_guid}/members/#{guid}/credentials"
  credential_response = ::Atrium.client.make_request(:get, endpoint)

  return nil if credential_response.nil?

  credential_params = credential_response["credentials"]

  credential_params.map do |credential|
    ::Atrium::Credential.new(credential)
  end
end

#deleteObject



100
101
102
103
104
105
# File 'lib/atrium/member.rb', line 100

def delete
  endpoint = "/users/#{user_guid}/members/#{guid}"
  ::Atrium.client.make_request(:delete, endpoint)

  self
end

#each_account(options = {}) ⇒ Object



59
60
61
62
# File 'lib/atrium/member.rb', line 59

def (options = {})
  options = (options)
  self.class.paginate_each(options) { || yield  }
end

#each_transaction(options = {}) ⇒ Object



153
154
155
156
# File 'lib/atrium/member.rb', line 153

def each_transaction(options = {})
  options = _transaction_pagination_options(options)
  self.class.paginate_each(options) { |transaction| yield transaction }
end

#read_account(account_guid:) ⇒ Object



107
108
109
110
111
112
113
# File 'lib/atrium/member.rb', line 107

def (account_guid:)
  endpoint = "/users/#{user_guid}/members/#{guid}/accounts/#{}"
   = ::Atrium.client.make_request(:get, endpoint)

   = ["account"]
  ::Atrium::Account.new()
end

#resume(challenge_credentials) ⇒ Object



115
116
117
118
119
120
121
122
123
# File 'lib/atrium/member.rb', line 115

def resume(challenge_credentials)
  endpoint = "/users/#{user_guid}/members/#{guid}/resume"
  body = resume_params(challenge_credentials)
  member_response = ::Atrium.client.make_request(:put, endpoint, body)

  member_params = member_response["member"]
  assign_attributes(member_params)
  self
end

#transactions(options = {}) ⇒ Object



148
149
150
151
# File 'lib/atrium/member.rb', line 148

def transactions(options = {})
  options = _transaction_pagination_options(options)
  self.class.paginate(options)
end

#transactions_in_batches(options = {}) ⇒ Object



158
159
160
161
# File 'lib/atrium/member.rb', line 158

def transactions_in_batches(options = {})
  options = _transaction_pagination_options(options)
  self.class.paginate_in_batches(options) { |batch| yield batch }
end

#update(params) ⇒ Object



125
126
127
128
129
130
131
132
133
# File 'lib/atrium/member.rb', line 125

def update(params)
  endpoint = "/users/#{user_guid}/members/#{guid}"
  body = member_body(params)
  member_response = ::Atrium.client.make_request(:put, endpoint, body)

  member_params = member_response["member"]
  assign_attributes(member_params)
  self
end