ahub 0.1.13 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/README.md +6 -0
- data/ahub.gemspec +1 -1
- data/lib/ahub/answer.rb +8 -10
- data/lib/ahub/modules/api_helpers.rb +7 -0
- data/lib/ahub/question.rb +3 -9
- data/lib/ahub/user.rb +0 -2
- data/lib/ahub/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b11c85492d4dbe8a0a35913bedbd0923981f80e1
|
4
|
+
data.tar.gz: dcae934db479bb0d7b68f909ca0c69cadba49534
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dac6d749ab6a169a0bb54836aacad9c27fee939b0516c8b919f91b2fe32d8c36e40c255ac2f182cedc88de0c1887306b0a4ed8963a856793f1d4d96dadd72961
|
7
|
+
data.tar.gz: 41d75ed0904baa303c3db587b13f1f7a9984eaef9afa82120e1e840be5f6cff5866ff646d1418002cc1ccdc35f35d01419f3e6b0c3d2678bd6843f0b17c2e41e
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# Ahub
|
2
2
|
A gem to interact with the [Answer Hub API](docs.answerhubapiv2.apiary.io)
|
3
3
|
|
4
|
+
Master
|
5
|
+
[![Build Status](https://travis-ci.org/abelmartin/ahub.svg?branch=master)](https://travis-ci.org/abelmartin/ahub)
|
6
|
+
|
7
|
+
Gem v0.1.13
|
8
|
+
[![Build Status](https://travis-ci.org/abelmartin/ahub.svg?branch=v0.1.13)](https://github.com/abelmartin/ahub/tree/v0.1.13)
|
9
|
+
|
4
10
|
## Installation
|
5
11
|
|
6
12
|
Add this line to your application's Gemfile:
|
data/ahub.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["abel.martin@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = "A gem to interact with the Answer Hub API"
|
13
|
-
spec.description = "Answer Hub is a great product. This gem allows you to easily interact with
|
13
|
+
spec.description = "Answer Hub is a great product. This gem allows you to easily interact with its API"
|
14
14
|
spec.homepage = "https://github.com/abelmartin/ahub"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
data/lib/ahub/answer.rb
CHANGED
@@ -3,6 +3,14 @@ module Ahub
|
|
3
3
|
extend Ahub::APIHelpers
|
4
4
|
include Ahub::ClassHelpers
|
5
5
|
|
6
|
+
def self.create(question_id:, body:, username:, password:)
|
7
|
+
payload = {body: body}
|
8
|
+
|
9
|
+
url = "#{Ahub::DOMAIN}/services/v2/question/#{question_id}/answer.json"
|
10
|
+
|
11
|
+
make_post_call(url, payload.to_json, headers(username: username, password: password))
|
12
|
+
end
|
13
|
+
|
6
14
|
attr_reader :body, :body_as_html, :author
|
7
15
|
|
8
16
|
def initialize(attrs)
|
@@ -15,15 +23,5 @@ module Ahub
|
|
15
23
|
def user
|
16
24
|
@author
|
17
25
|
end
|
18
|
-
|
19
|
-
def self.create(question_id:, body:, username:, password:)
|
20
|
-
data = {body: body}
|
21
|
-
|
22
|
-
url = "#{Ahub::DOMAIN}/services/v2/question/#{question_id}/answer.json"
|
23
|
-
|
24
|
-
auth_headers = headers(username: username, password: password)
|
25
|
-
|
26
|
-
new JSON.parse(RestClient.post(url, data.to_json, auth_headers), symbolize_names: true)
|
27
|
-
end
|
28
26
|
end
|
29
27
|
end
|
@@ -44,5 +44,12 @@ module Ahub
|
|
44
44
|
def object_id_from_response(response)
|
45
45
|
response.headers[:location].match(/(?<id>\d*)\.json/)[:id].to_i
|
46
46
|
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def make_post_call(url:, payload:, headers:)
|
51
|
+
response = RestClient.post(url, payload.to_json, admin_headers)
|
52
|
+
find(object_id_from_response(response))
|
53
|
+
end
|
47
54
|
end
|
48
55
|
end
|
data/lib/ahub/question.rb
CHANGED
@@ -3,8 +3,8 @@ module Ahub
|
|
3
3
|
extend Ahub::APIHelpers
|
4
4
|
include Ahub::ClassHelpers
|
5
5
|
|
6
|
-
attr_accessor :title, :body, :body_as_html, :author
|
7
|
-
attr_reader :space_id
|
6
|
+
attr_accessor :title, :body, :body_as_html, :author
|
7
|
+
attr_reader :space_id, :answerCount
|
8
8
|
|
9
9
|
def self.create(title:, body:, topics:, space_id: nil, username:, password:)
|
10
10
|
url = "#{base_url}.json"
|
@@ -13,11 +13,7 @@ module Ahub
|
|
13
13
|
|
14
14
|
user_headers = headers(username:username, password:password)
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
find(object_id_from_response(response))
|
19
|
-
rescue => e
|
20
|
-
new({error: e.message})
|
16
|
+
make_post_call(url: url, payload: payload.to_json, headers: user_headers)
|
21
17
|
end
|
22
18
|
|
23
19
|
def initialize(attrs)
|
@@ -35,8 +31,6 @@ module Ahub
|
|
35
31
|
|
36
32
|
move_url = "#{self.class.base_url}/#{id}/move.json?space=#{space_id}"
|
37
33
|
RestClient.put("#{url}", self.class.admin_headers)
|
38
|
-
rescue => e
|
39
|
-
@error = e.message
|
40
34
|
end
|
41
35
|
|
42
36
|
def url
|
data/lib/ahub/user.rb
CHANGED
data/lib/ahub/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ahub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abel Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '3.2'
|
97
97
|
description: Answer Hub is a great product. This gem allows you to easily interact
|
98
|
-
with
|
98
|
+
with its API
|
99
99
|
email:
|
100
100
|
- abel.martin@gmail.com
|
101
101
|
executables:
|