Project

ammado

0.0
No commit activity in last 3 years
No release in over 3 years
Using Ammado API with Ruby (and Rails). https://api.ammado.com/
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.0
~> 2.0.1
~> 3.12

Runtime

 Project Readme

AMMADO API FOR RUBY (AND RAILS)

Contribution

Please help to make this GEM better

  • by creating a Issue and then Pull Request with a fix to this Issue.
  • support its improvement with a donation.

Ammado API reference

https://api.ammado.com/

Configuration

First define API link:

require 'ammado'

Ammado::Api.default_api_link = Ammado::Api.new(
  key: "AMMADO_API_KEY_HERE",
  secret: "AMMADO_API_KEY_HERE",
  host: 'https://api.ammado.com/',
  default_images_folder: '/folder/for/files/'
)

Note:

This configuration might have issues in threaded environments. Simple fix would be defining only parameters, and when needed, creating a instance in ApiResource based on this configuration.

If issue exists see Contribution.

Implemented Endpoints and their usage

Note: you acn use parameter names both "model.beneficiary_id" and "model.beneficiaryId", but for better readibility and following Ruby standards, I recommend under_scored, not camelCase.

All the existing params can be set with "model.some_param=value" and "model.someParam=value".

To read all the params use "model.params" containing all the resource params.

ammado_fundraiser = Ammado::Fundraiser.create(
  beneficiary_id: '123',
  fundraiser_title: 'Title',
  fundraiser_description: 'Description',
  target_amount: '10.00',
  target_currency_code: 'EUR',
  thank_you_message: 'Thank you for the donation.'
)

if ammado_fundraiser.created?
  puts "Created a fundraiser, with permalink: #{ ammado_fundraiser.permalink }"
else
  puts "Failed to create fundraiser and got errors"
  puts ammando_fundraiser.errors.map(&:message).join(', ')
end

puts "All params for fundraiser are: #{ ammado_fundraiser.params.inspect }"
ammado_beneficiary = Ammado::Beneficiary.find(123)

if ammado_beneficiary
  puts "Found a beneficiary, with type: "
  puts ammado_beneficiary.beneficiary_type
  puts "With raised amount: "
  puts ammado_beneficiary.raised_amount
else
  puts "Beneficiary not found"
end

puts "All params for ammado_beneficiary are: #{ ammado_beneficiary.params.inspect }"
fundraiser_id = ammado_fundraiser.permalink.split('/').last

ammado_fundraiser_moderator = Ammado::FundraiserModerator.create(
  fundraiser_id: fundraiser_id,
  first_name: name,
  last_name: lastname,
  email: email
)

if ammado_fundraiser_moderator.created?
  puts "Created a moderator, with params: #{ ammado_fundraiser_moderator.params.inspect }"
else
  puts "Failed to create fundraiser and got errors"
  puts ammando_fundraiser.errors.map(&:message).join(', ')
end
fundraiser_id = ammado_fundraiser.permalink.split('/').last

ammado_fundraiser_moderator = Ammado::FundraiserModerator.create(
  fundraiser_id: fundraiser_id,
  first_name: name,
  last_name: lastname,
  email: email
)

if ammado_fundraiser_moderator.created?
  puts "Created a moderator, with params: #{ ammado_fundraiser_moderator.params.inspect }"
else
  puts "Failed to create fundraiser and got errors"
  puts ammando_fundraiser.errors.map(&:message).join(', ')
end
fundraiser_id = ammado_fundraiser.permalink.split('/').last

ammado_fundraiser_avatar = Ammado::FundraiserAvatar.create(
  fundraiser_id: fundraiser_id,
  file_name: 'fundraiser_avatar.png'
)

if ammado_fundraiser_avatar.created?
  puts "Created a moderator, with params: #{ ammado_fundraiser_avatar.params.inspect }"
else
  puts "Failed to create ammado_fundraiser_avatar and got errors"
  puts ammado_fundraiser_avatar.errors.map(&:message).join(', ')
end
fundraiser_id = ammado_fundraiser.permalink.split('/').last

ammado_fundraiser_cover = Ammado::FundraiserCover.create(
  fundraiser_id: fundraiser_id,
  file_name: 'fundraiser_cover.png'
)

if ammado_fundraiser_cover.created?
  puts "Created a moderator, with params: #{ ammado_fundraiser_cover.params.inspect }"
else
  puts "Failed to create ammado_fundraiser_cover and got errors: "
  puts ammado_fundraiser_cover.errors.map(&:message).join(', ')
end
  categories = Ammado::Categories.all
  found = Ammado::Search.where(search_params)

Author

Margus Pärt (http://wave.ee)