Class: Dotloop::Participant
- Inherits:
-
Object
- Object
- Dotloop::Participant
- Includes:
- ParseData
- Defined in:
- lib/dotloop/participant.rb
Constant Summary collapse
- PARTICIPANT_FIELDS =
[ 'fullName', 'email', 'role', 'Street Name', 'Street Number', 'City', 'State/Prov', 'Zip/Postal Code', 'Unit Number', 'Country', 'Phone', 'Cell Phone', 'Company Name' ].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
Methods included from ParseData
Constructor Details
#initialize(client:) ⇒ Participant
Returns a new instance of Participant.
24 25 26 |
# File 'lib/dotloop/participant.rb', line 24 def initialize(client:) @client = client end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
6 7 8 |
# File 'lib/dotloop/participant.rb', line 6 def client @client end |
Instance Method Details
#all(profile_id:, loop_id:) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dotloop/participant.rb', line 28 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_data = parse_data(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
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/dotloop/participant.rb', line 49 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_data = parse_data(participant_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
79 80 81 |
# File 'lib/dotloop/participant.rb', line 79 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
39 40 41 42 43 44 45 46 47 |
# File 'lib/dotloop/participant.rb', line 39 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_data = parse_data(participant_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
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/dotloop/participant.rb', line 64 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_data = parse_data(participant_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 |