nimbu-api 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +92 -16
- data/lib/nimbu-api/configuration.rb +1 -1
- data/lib/nimbu-api/connection.rb +1 -1
- data/lib/nimbu-api/version.rb +1 -1
- data/vendor/cacert.pem +3895 -0
- metadata +60 -91
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7fe69fea88b50f988c783136e7c5be19e292f47d
|
4
|
+
data.tar.gz: ef2bf03366e0a6fe07b83cf5425d57b93786e0ae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4f90a9016cabb405549fd2772d589d41c8d49083bb454ad78884feace8782586e62f3f2b35bd155c55f16c8e925600b919c34c56a05f02b85eb7d0b6d04507a0
|
7
|
+
data.tar.gz: 3346bb86971830621b67428e2b124c0799e0d0a150c3b6d012b58c4c5e06be2336fa37dfb8cec91d10db5cb4429c0a2dbe7b051c3872d19ade36bcb68350e40e
|
data/README.md
CHANGED
@@ -1,29 +1,105 @@
|
|
1
|
-
#
|
1
|
+
# NimbuAPI
|
2
2
|
|
3
|
-
|
3
|
+
[](http://badge.fury.io/rb/nimbu-api)
|
4
|
+
|
5
|
+
A Ruby wrapper for the Nimbu API.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
7
|
-
|
9
|
+
Install the gem by issuing
|
8
10
|
|
9
|
-
|
11
|
+
```ruby
|
12
|
+
gem install nimbu-api
|
13
|
+
```
|
10
14
|
|
11
|
-
|
15
|
+
or put it in your Gemfile and run `bundle install`
|
12
16
|
|
13
|
-
|
17
|
+
```ruby
|
18
|
+
gem "nimbu-api"
|
19
|
+
```
|
14
20
|
|
15
|
-
|
21
|
+
## Usage
|
16
22
|
|
17
|
-
|
23
|
+
To use the gem, create a new client instance
|
18
24
|
|
19
|
-
|
25
|
+
```ruby
|
26
|
+
nimbu = Nimbu.new
|
27
|
+
```
|
28
|
+
|
29
|
+
You can supply following configuration parameters, such as
|
30
|
+
```
|
31
|
+
auto_pagination # by default false, set to true traverses requests page links
|
32
|
+
oauth_token # oauth authorization token
|
33
|
+
basic_auth # login:password string
|
34
|
+
client_id # oauth client id
|
35
|
+
client_secret # oauth client secret
|
36
|
+
subdomain # the nimbu administration subdomain used in requets if none provided
|
37
|
+
endpoint # nimbu enterprise api endpoint
|
38
|
+
site # nimbu enterprise api web endpoint
|
39
|
+
ssl # ssl settings
|
40
|
+
per_page # number of items per page, max 100
|
41
|
+
user_agent # custom user agent name, by default 'Nimbu Ruby Client'
|
42
|
+
```
|
43
|
+
which are used throughout the API. These can be passed directly as hash options:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
nimbu = Nimbu.new oauth_token: 'token'
|
47
|
+
```
|
48
|
+
|
49
|
+
Alternatively, you can configure the Nimbu settings by passing a block, for instance, with custom enterprise endpoint and website like
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
nimbu = Nimbu.new do |config|
|
53
|
+
config.endpoint = 'https://api.company.com'
|
54
|
+
config.site = 'https://www.company.com'
|
55
|
+
config.oauth_token = 'token'
|
56
|
+
config.ssl = {:verify => false}
|
57
|
+
end
|
58
|
+
```
|
59
|
+
|
60
|
+
You can authenticate either using OAuth authentication or through basic authentication by passing your login and password:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
nimbu = Nimbu.new login:'peter', password:'...'
|
64
|
+
```
|
65
|
+
|
66
|
+
or use following convenience method:
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
nimbu = Nimbu.new basic_auth: 'login:password'
|
70
|
+
```
|
71
|
+
|
72
|
+
This gem follows the Nimbu API hierarchy. This means, i.e. if you want to create a new entry for a given channel,
|
73
|
+
you can lookup the nimbu api spec and parse the request as in `nimbu.channels(channel_id: 'mychannel').entries.create`
|
74
|
+
|
75
|
+
The response is always of type [Hashie::Mash] and allows to traverse all the json response attributes like method calls i.e.
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
entries = Nimbu::Channel::Entries.new :oauth_token => '...', :subdomain => '...', :channel_id => '...'
|
79
|
+
entries.all do |entry|
|
80
|
+
puts entry.title
|
81
|
+
end
|
82
|
+
```
|
83
|
+
|
84
|
+
## Arguments & Parameters
|
85
|
+
|
86
|
+
The library allows for flexible arguments parsing. This means arguments can be passed during instance creation:
|
87
|
+
|
88
|
+
```ruby
|
89
|
+
channel = Nimbu::Channel.new :oauth_token => '...', :subdomain => '...', :channel_id => '...'
|
90
|
+
channel.entries.list state: 'public'
|
91
|
+
```
|
92
|
+
|
93
|
+
Further, arguments can be passed directly inside method called but then the order of parameters matters and hence please consult the method documentation or Nimbu specification. For instance:
|
20
94
|
|
21
|
-
|
95
|
+
```ruby
|
96
|
+
channel = Nimbu::Channel.new :oauth_token => '...', :subdomain => '...'
|
97
|
+
channel.entries.list channel_id: '...', state: 'public'
|
98
|
+
```
|
22
99
|
|
23
|
-
|
100
|
+
Similarly, the arguments for the request can be passed inside the current scope such as:
|
24
101
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
5. Create new Pull Request
|
102
|
+
```ruby
|
103
|
+
channel = Nimbu::Channel.new :oauth_token => '...', :subdomain => '...'
|
104
|
+
channel.entries(channel_id: '...').list(state: 'public')
|
105
|
+
```
|
@@ -52,7 +52,7 @@ module Nimbu
|
|
52
52
|
DEFAULT_SSL = {}
|
53
53
|
|
54
54
|
# The value sent in the http header for 'User-Agent' if none is set
|
55
|
-
DEFAULT_USER_AGENT = "
|
55
|
+
DEFAULT_USER_AGENT = "nimbu-api/#{Nimbu::API::VERSION} (#{RUBY_PLATFORM}) ruby/#{RUBY_VERSION}".freeze
|
56
56
|
|
57
57
|
# By default the <tt>Accept</tt> header will make a request for <tt>JSON</tt>
|
58
58
|
DEFAULT_MIME_TYPE = :json
|
data/lib/nimbu-api/connection.rb
CHANGED
@@ -74,7 +74,7 @@ module Nimbu
|
|
74
74
|
# Returns a Fraday::Connection object
|
75
75
|
#
|
76
76
|
def connection(options={})
|
77
|
-
conn_options = default_options(options)
|
77
|
+
conn_options = default_options({ :ssl => { :ca_file => File.expand_path("../../../vendor/cacert.pem", __FILE__) } }.merge(options))
|
78
78
|
clear_cache unless options.empty?
|
79
79
|
puts "OPTIONS:#{conn_options.inspect}" if ENV['DEBUG']
|
80
80
|
|
data/lib/nimbu-api/version.rb
CHANGED