Class: Dotloop::Participant
- Inherits:
-
Object
- Object
- Dotloop::Participant
- Defined in:
- lib/dotloop/participant.rb
Constant Summary collapse
- PARTICIPANT_FIELDS =
%w[fullName email role].freeze
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #all(profile_id:, loop_id:) ⇒ Object
- #create(profile_id:, loop_id:, params: {}) ⇒ Object
- #delete(profile_id:, loop_id:, participant_id:) ⇒ Object
- #find(profile_id:, loop_id:, participant_id:) ⇒ Object
-
#initialize(client:) ⇒ Participant
constructor
A new instance of Participant.
- #update(profile_id:, loop_id:, participant_id:, params: {}) ⇒ Object
Constructor Details
#initialize(client:) ⇒ Participant
Returns a new instance of Participant.
9 10 11 |
# File 'lib/dotloop/participant.rb', line 9 def initialize(client:) @client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
5 6 7 |
# File 'lib/dotloop/participant.rb', line 5 def client @client end |
Instance Method Details
#all(profile_id:, loop_id:) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/dotloop/participant.rb', line 13 def all(profile_id:, loop_id:) @client.get("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/participant")[:data].map do |participant_attrs| participant = Dotloop::Models::Participant.new(participant_attrs) participant.client = client participant.profile_id = profile_id.to_i participant.loop_id = loop_id.to_i participant end end |
#create(profile_id:, loop_id:, params: {}) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/dotloop/participant.rb', line 32 def create(profile_id:, loop_id:, params: {}) data = {} params.each do |key, value| PARTICIPANT_FIELDS.include?(key.to_s) || next data[key] = value.to_s end participant_data = @client.post("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/participant", data)[:data] participant = Dotloop::Models::Participant.new(participant_data) participant.client = client participant.profile_id = profile_id.to_i participant.loop_id = loop_id.to_i participant end |
#delete(profile_id:, loop_id:, participant_id:) ⇒ Object
62 63 64 |
# File 'lib/dotloop/participant.rb', line 62 def delete(profile_id:, loop_id:, participant_id:) @client.delete("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/participant/#{participant_id.to_i}") end |
#find(profile_id:, loop_id:, participant_id:) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/dotloop/participant.rb', line 23 def find(profile_id:, loop_id:, participant_id:) participant_data = @client.get("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/participant/#{participant_id.to_i}")[:data] participant = Dotloop::Models::Participant.new(participant_data) participant.client = client participant.profile_id = profile_id.to_i participant.loop_id = loop_id.to_i participant end |
#update(profile_id:, loop_id:, participant_id:, params: {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/dotloop/participant.rb', line 47 def update(profile_id:, loop_id:, participant_id:, params: {}) data = {} params.each do |key, value| PARTICIPANT_FIELDS.include?(key.to_s) || next data[key] = value.to_s end participant_data = @client.patch("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/participant/#{participant_id.to_i}", data)[:data] participant = Dotloop::Models::Participant.new(participant_data) participant.client = client participant.profile_id = profile_id.to_i participant.loop_id = loop_id.to_i participant end |