Class: TodoApi::Cli::Lists
- Inherits:
-
Object
- Object
- TodoApi::Cli::Lists
- Defined in:
- lib/todo_api_cli.rb
Class Method Summary collapse
-
.client ⇒ Object
ugly as fuck.
- .create(name:) ⇒ Object
Class Method Details
.client ⇒ Object
ugly as fuck. Need to split this classes into different scopes and extrac this into a Faraday client module
47 48 49 50 51 52 53 54 55 |
# File 'lib/todo_api_cli.rb', line 47 def self.client @@conn ||= Faraday.new(url: TodoApi::API_URL) do |f| f.request :url_encoded f.adapter Faraday.default_adapter f.request :url_encoded f.request :json f.response :json, content_type: /\bjson$/ end end |
.create(name:) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/todo_api_cli.rb', line 37 def self.create(name:) client.post do |req| req.url '/lists' req.body = { name: name }.to_json req.headers['Authorization'] = Keychain.generic_passwords.where(:service =>'todo-api').first&.password end end |