Class: Kentaa::Api::Resources::Project

Inherits:
Resource show all
Defined in:
lib/kentaa/api/resources/project.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

#actionsObject



180
181
182
# File 'lib/kentaa/api/resources/project.rb', line 180

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

#activitiesObject



200
201
202
# File 'lib/kentaa/api/resources/project.rb', line 200

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

#closed?Boolean

Returns:

  • (Boolean)


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

def closed?
  data[:closed]
end


152
153
154
155
156
# File 'lib/kentaa/api/resources/project.rb', line 152

def consent
  Kentaa::Api::Deprecation.warn('#consent is deprecated. Please use #consents instead.', caller)

  @consent ||= Kentaa::Api::Resources::Consent.new(data[:consent]) if data[:consent]
end

#consentsObject



158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/kentaa/api/resources/project.rb', line 158

def consents
  @consents ||= begin
    consents = []

    if data[:consents]
      data[:consents].each do |consent|
        consents << Kentaa::Api::Resources::Consent.new(consent)
      end
    end

    consents
  end
end

#contactObject



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

def contact
  @contact ||= Kentaa::Api::Resources::Contact.new(data[:contact]) if data[:contact]
end

#countable?Boolean

Returns:

  • (Boolean)


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

def countable?
  data[:countable]
end

#descriptionObject



46
47
48
# File 'lib/kentaa/api/resources/project.rb', line 46

def description
  data[:description]
end


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

def donate_url
  data[:donate_url]
end

#donationsObject



188
189
190
# File 'lib/kentaa/api/resources/project.rb', line 188

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

#end_dateObject



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

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

#ended?Boolean

Returns:

  • (Boolean)


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

def ended?
  data[:ended]
end

#external_referenceObject



176
177
178
# File 'lib/kentaa/api/resources/project.rb', line 176

def external_reference
  data[:external_reference]
end

#has_target_amount?Boolean

Returns:

  • (Boolean)


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

def has_target_amount?
  data[:has_target_amount]
end

#hideObject



216
217
218
# File 'lib/kentaa/api/resources/project.rb', line 216

def hide
  request.post("/projects/#{id}/hide")
end

#locationObject



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

def location
  @location ||= Kentaa::Api::Resources::Location.new(data[:location]) if data[:location]
end

#manual_donationsObject



192
193
194
# File 'lib/kentaa/api/resources/project.rb', line 192

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

#newsObject



204
205
206
# File 'lib/kentaa/api/resources/project.rb', line 204

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

#newsletter_subscriptionsObject



196
197
198
# File 'lib/kentaa/api/resources/project.rb', line 196

def newsletter_subscriptions
  @newsletter_subscriptions ||= Kentaa::Api::Resources::List.new(config, resource_class: Kentaa::Api::Resources::NewsletterSubscription, endpoint_path: "/projects/#{id}/newsletter-subscriptions")
end

#object_keyObject



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

def object_key
  "Project_#{id}"
end

#ordersObject



208
209
210
# File 'lib/kentaa/api/resources/project.rb', line 208

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

#parentObject



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

def parent
  if 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



110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/kentaa/api/resources/project.rb', line 110

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

#public_idObject



26
27
28
# File 'lib/kentaa/api/resources/project.rb', line 26

def public_id
  data[:public_id]
end

#publishObject



212
213
214
# File 'lib/kentaa/api/resources/project.rb', line 212

def publish
  request.post("/projects/#{id}/publish")
end

#publishable?Boolean

Returns:

  • (Boolean)


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

def publishable?
  data[:publishable]
end

#published_atObject



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

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

#questionsObject



138
139
140
141
142
143
144
145
146
147
148
149
150
# File 'lib/kentaa/api/resources/project.rb', line 138

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



38
39
40
# File 'lib/kentaa/api/resources/project.rb', line 38

def segment_id
  data[:segment_id]
end

#showObject



220
221
222
# File 'lib/kentaa/api/resources/project.rb', line 220

def show
  request.post("/projects/#{id}/show")
end

#siteObject



22
23
24
# File 'lib/kentaa/api/resources/project.rb', line 22

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

#site_idObject



34
35
36
# File 'lib/kentaa/api/resources/project.rb', line 34

def site_id
  data[:site_id]
end

#slugObject



30
31
32
# File 'lib/kentaa/api/resources/project.rb', line 30

def slug
  data[:slug]
end

#target_amountObject



50
51
52
# File 'lib/kentaa/api/resources/project.rb', line 50

def target_amount
  data[:target_amount]
end

#target_amount_achieved?Boolean

Returns:

  • (Boolean)


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

def target_amount_achieved?
  data[:target_amount_achieved]
end

#teamsObject



184
185
186
# File 'lib/kentaa/api/resources/project.rb', line 184

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

#titleObject



42
43
44
# File 'lib/kentaa/api/resources/project.rb', line 42

def title
  data[:title]
end

#total_amountObject



54
55
56
# File 'lib/kentaa/api/resources/project.rb', line 54

def total_amount
  BigDecimal(data[:total_amount])
end

#total_donationsObject



58
59
60
# File 'lib/kentaa/api/resources/project.rb', line 58

def total_donations
  data[:total_donations]
end

#urlObject



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

def url
  data[:url]
end

#videosObject



124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/kentaa/api/resources/project.rb', line 124

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)


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

def visible?
  data[:visible]
end