Class: Kentaa::Api::Resources::Team

Inherits:
Resource show all
Defined in:
lib/kentaa/api/resources/team.rb

Instance Attribute Summary

Attributes inherited from Resource

#id

Attributes inherited from Base

#config, #endpoint_path, #options, #resource_class

Instance Method Summary collapse

Methods inherited from Resource

#create, #created_at, #delete, #initialize, #load, #save, #updated_at

Methods inherited from Base

attribute_key, #initialize, #load, #loaded?

Constructor Details

This class inherits a constructor from Kentaa::Api::Resources::Resource

Instance Method Details

#closed?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/kentaa/api/resources/team.rb', line 102

def closed?
  data[:closed]
end

#countable?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/kentaa/api/resources/team.rb', line 98

def countable?
  data[:countable]
end

#descriptionObject



70
71
72
# File 'lib/kentaa/api/resources/team.rb', line 70

def description
  data[:description]
end


118
119
120
# File 'lib/kentaa/api/resources/team.rb', line 118

def donate_url
  data[:donate_url]
end

#donationsObject



168
169
170
# File 'lib/kentaa/api/resources/team.rb', line 168

def donations
  @donations ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::Donation, endpoint_path: "/teams/#{id}/donations")
end

#end_dateObject



110
111
112
# File 'lib/kentaa/api/resources/team.rb', line 110

def end_date
  Time.parse(data[:end_date]) if data[:end_date]
end

#ended?Boolean

Returns:

  • (Boolean)


106
107
108
# File 'lib/kentaa/api/resources/team.rb', line 106

def ended?
  data[:ended]
end

#external_referenceObject



164
165
166
# File 'lib/kentaa/api/resources/team.rb', line 164

def external_reference
  data[:external_reference]
end

#manual_donationsObject



172
173
174
# File 'lib/kentaa/api/resources/team.rb', line 172

def manual_donations
  @manual_donations ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::ManualDonation, endpoint_path: "/teams/#{id}/manual-donations")
end

#membersObject



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/kentaa/api/resources/team.rb', line 48

def members
  @members ||= begin
    members = []

    if data[:members]
      data[:members].each do |member|
        members << Kentaa::Api::Resources::Action.new(config, data: member, options: options)
      end
    end

    members
  end
end

#nameObject



62
63
64
# File 'lib/kentaa/api/resources/team.rb', line 62

def name
  data[:name]
end

#object_keyObject



10
11
12
# File 'lib/kentaa/api/resources/team.rb', line 10

def object_key
  "Team_#{id}"
end

#ownerObject



44
45
46
# File 'lib/kentaa/api/resources/team.rb', line 44

def owner
  @owner ||= Kentaa::Api::Resources::User.new(config, data: data[:owner], options: options)
end

#parentObject



14
15
16
17
18
19
20
21
22
# File 'lib/kentaa/api/resources/team.rb', line 14

def parent
  if project_id
    Kentaa::Api::Resources::Project.new(config, id: project_id, options: options)
  elsif segment_id
    Kentaa::Api::Resources::Segment.new(config, id: segment_id, options: options)
  else
    Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
  end
end

#photosObject



122
123
124
125
126
127
128
129
130
131
132
133
134
# File 'lib/kentaa/api/resources/team.rb', line 122

def photos
  @photos ||= begin
    photos = []

    if data[:photos]
      data[:photos].each do |photo|
        photos << Kentaa::Api::Resources::Photo.new(photo)
      end
    end

    photos
  end
end

#project_idObject



40
41
42
# File 'lib/kentaa/api/resources/team.rb', line 40

def project_id
  data[:project_id]
end

#questionsObject



150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/kentaa/api/resources/team.rb', line 150

def questions
  @questions ||= begin
    questions = []

    if data[:questions]
      data[:questions].each do |question|
        questions << Kentaa::Api::Resources::Question.new(question)
      end
    end

    questions
  end
end

#segment_idObject



36
37
38
# File 'lib/kentaa/api/resources/team.rb', line 36

def segment_id
  data[:segment_id]
end

#siteObject



24
25
26
# File 'lib/kentaa/api/resources/team.rb', line 24

def site
  Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
end

#site_idObject



32
33
34
# File 'lib/kentaa/api/resources/team.rb', line 32

def site_id
  data[:site_id]
end

#slugObject



28
29
30
# File 'lib/kentaa/api/resources/team.rb', line 28

def slug
  data[:slug]
end

#target_amountObject



78
79
80
# File 'lib/kentaa/api/resources/team.rb', line 78

def target_amount
  data[:target_amount]
end

#target_amount_achieved?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/kentaa/api/resources/team.rb', line 90

def target_amount_achieved?
  data[:target_amount_achieved]
end

#titleObject



66
67
68
# File 'lib/kentaa/api/resources/team.rb', line 66

def title
  data[:title]
end

#total_amountObject



82
83
84
# File 'lib/kentaa/api/resources/team.rb', line 82

def total_amount
  BigDecimal(data[:total_amount])
end

#total_donationsObject



86
87
88
# File 'lib/kentaa/api/resources/team.rb', line 86

def total_donations
  data[:total_donations]
end

#total_team_membersObject



74
75
76
# File 'lib/kentaa/api/resources/team.rb', line 74

def total_team_members
  data[:total_team_members]
end

#urlObject



114
115
116
# File 'lib/kentaa/api/resources/team.rb', line 114

def url
  data[:url]
end

#videosObject



136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/kentaa/api/resources/team.rb', line 136

def videos
  @videos ||= begin
    videos = []

    if data[:videos]
      data[:videos].each do |video|
        videos << Kentaa::Api::Resources::Video.new(video)
      end
    end

    videos
  end
end

#visible?Boolean

Returns:

  • (Boolean)


94
95
96
# File 'lib/kentaa/api/resources/team.rb', line 94

def visible?
  data[:visible]
end