Module: Kip::API

Extended by:
API
Included in:
API
Defined in:
lib/kip/api.rb

Instance Method Summary collapse

Instance Method Details

#create_new_post(title, tags, content, draft) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/kip/api.rb', line 14

def create_new_post(title, tags, content, draft)
  request = Net::HTTP::Post.new("/api/v1/post")
  request["X-Kipalog-Token"] = self.get_api_token
  body = { 
    title: title,
    content: content,
    status: (draft) ? "draft" : "published",
    tag: tags
  }
  request.body = body.to_json
  response = @http.request(request)
  puts response.body
end

#get_api_tokenObject



10
11
12
# File 'lib/kip/api.rb', line 10

def get_api_token
  return ENV["KIPALOG_API"]
end