Class: Slurper::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/slurper/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#list_idObject (readonly)

Returns the value of attribute list_id.



5
6
7
# File 'lib/slurper/client.rb', line 5

def list_id
  @list_id
end

#write_tokenObject (readonly)

Returns the value of attribute write_token.



5
6
7
# File 'lib/slurper/client.rb', line 5

def write_token
  @write_token
end

Instance Method Details

#create_card(story) ⇒ Object



22
23
24
25
# File 'lib/slurper/client.rb', line 22

def create_card(story)
  url = "https://trello.com/1/lists/#{list_id}/cards?key=#{Slurper::Config.trello_application_key}&token=#{write_token}"
  Typhoeus.post url, body: story.to_post_params
end

#create_listObject



17
18
19
20
# File 'lib/slurper/client.rb', line 17

def create_list
  url = "https://trello.com/1/boards/#{Slurper::Config.trello_board_id}/lists?key=#{Slurper::Config.trello_application_key}&token=#{write_token}&name=Slurper%20Import"
  @list_id = JSON.parse(Typhoeus.post(url).body)["id"]
end

#get_trello_write_tokenObject



7
8
9
10
11
12
13
14
15
# File 'lib/slurper/client.rb', line 7

def get_trello_write_token
  url = "https://trello.com/1/authorize?key=#{Slurper::Config.trello_application_key}&name=Slurper%20for%20Trello&expiration=1day&response_type=token&scope=read%2Cwrite"
  puts "You must provide a write-enabled Trello API token."
  puts "Ensure you're logged into Trello, then press the <ENTER> key to open a browser window to fetch this token."
  _ = gets
  `open "#{url}"`
  puts "Please paste your token."
  @write_token = gets.strip
end