Class: MingleParty
Instance Method Summary collapse
- #change_card_status(number, status) ⇒ Object
- #create_card(name, card_type) ⇒ Object
- #create_user(user) ⇒ Object
- #fetch_card(number) ⇒ Object
- #fetch_cards ⇒ Object
- #fetch_user(id) ⇒ Object
- #fetch_users ⇒ Object
-
#initialize ⇒ MingleParty
constructor
A new instance of MingleParty.
- #murmur(message, command) ⇒ Object
-
#murmurs ⇒ Object
def delete_card(number) self.class.delete( “#@uri/cards/#number”) end.
Constructor Details
#initialize ⇒ MingleParty
Returns a new instance of MingleParty.
8 9 10 11 12 13 |
# File 'lib/mingle_party.rb', line 8 def initialize config = YAML.load(File.read("./config.yml")).first @uri = "#{config['host']}/api/v2/projects/#{config['project']}" auth = { username: config['username'], password: config['password'] } @auth_options = { :basic_auth => auth } end |
Instance Method Details
#change_card_status(number, status) ⇒ Object
20 21 22 23 |
# File 'lib/mingle_party.rb', line 20 def change_card_status(number, status) = @auth_options.merge({ query: { 'card[properties[][name]' => 'status', 'card[properties][][value]' => status } }) response = self.class.put( "#{@uri}/cards/#{number}.xml", ) end |
#create_card(name, card_type) ⇒ Object
15 16 17 18 |
# File 'lib/mingle_party.rb', line 15 def create_card(name, card_type) = @auth_options.merge({ query: {'card[name]' => name, 'card[card_type_name]' => card_type } }) response = self.class.post("#{@uri}/cards.xml", ) end |
#create_user(user) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/mingle_party.rb', line 56 def create_user(user) = @auth_options.merge({ query: { 'user[name]' => user[:name], 'user[login]' => user[:login], 'user[email]' => user[:email], 'user[admin]' => user[:admin], 'user[password]' => user[:password], 'user[password_confirmation]' => user[:password_confirmation]} }) self.class.post("#{@uri}/users.xml", ) end |
#fetch_card(number) ⇒ Object
25 26 27 28 |
# File 'lib/mingle_party.rb', line 25 def fetch_card(number) response = self.class.get( "#{@uri}/cards/#{number}.xml", @auth_options ) Crack::XML.parse( response.body ) end |
#fetch_cards ⇒ Object
30 31 32 33 |
# File 'lib/mingle_party.rb', line 30 def fetch_cards response = self.class.get( "#{@uri}/cards.xml", @auth_options ) Crack::XML.parse( response.body ) end |
#fetch_user(id) ⇒ Object
69 70 71 72 |
# File 'lib/mingle_party.rb', line 69 def fetch_user(id) response = self.class.get( "#{@uri}/users/#{id}.xml", @auth_options ) Crack::XML.parse( response.body ) end |
#fetch_users ⇒ Object
64 65 66 67 |
# File 'lib/mingle_party.rb', line 64 def fetch_users response = self.class.get( "#{@uri}/users.xml", @auth_options ) Crack::XML.parse( response.body ) end |
#murmur(message, command) ⇒ Object
51 52 53 54 |
# File 'lib/mingle_party.rb', line 51 def murmur(, command) = @auth_options.merge( { query: { "#{command}".to_sym => } } ) response = self.class.post( "#{@uri}/murmurs.xml", ) end |
#murmurs ⇒ Object
def delete_card(number)
self.class.delete( "#{@uri}/cards/#{number}")
end
def delete_cards
response = fetch_cards
response['cards'].each{|card| delete_card(card['number'].to_i)}
response.each {|key, value| puts "#{key}" }
end
46 47 48 49 |
# File 'lib/mingle_party.rb', line 46 def murmurs response = self.class.get( "#{@uri}/murmurs.xml", @auth_options ) Crack::XML.parse( response.body )["murmurs"] end |