ecal_client 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8daafab5dc5cdc47ced7f977c95201531b499f0
4
- data.tar.gz: fdfe46107fa7c3f1885797e05669000e07175356
3
+ metadata.gz: baed85157042311b88b72862a71b294fb2b04a01
4
+ data.tar.gz: 34d419c1e2ecf28ef9ecc8ad746ec23a50a71ba3
5
5
  SHA512:
6
- metadata.gz: a837d770528b4448c7bfef5a0caa66fdc111e7c2fb8d9d107e58d9728c2cbe3e4eb2e24dd7080969138dbe4a1c937e17a90278b9939932e6f3a6ed44d646831f
7
- data.tar.gz: fad17f46fa28caefa171fc24bfaf4296a81cc341dbbeee2e81a74c0bacce28e4e50e19cc9468473c462fc4671dd8439727d7edda3e9f814a6862787ea6af5106
6
+ metadata.gz: 52d2bea0757d983ff4e5e89ca17e4691c525c1f8e0caab4aef0a0a7dc11c1022c7b8a022f682e76ff614dfb3c9c666c6abf2d58acd3474c7b0b3f64193cd8202
7
+ data.tar.gz: e4fc49a58d5f8eb31d1d0da16421dfb299d713b9c5ff0e649bfe3d09ab71520a217a83eac329a760382326328bf258d6ff5e6ece00c59a9b685c75b5307c77e6
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # EcalClient
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ecal_client`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Ruby Client for [Ecal](http://ecal.com/).
4
+
5
+ Ecal API documentation can be found [here](https://e-diary.atlassian.net/wiki/display/EAV/ECAL+API+V2+Home).
4
6
 
5
7
  ## Installation
6
8
 
@@ -23,7 +23,7 @@ module EcalClient
23
23
 
24
24
  def api_sign(parameters = {}, body = nil)
25
25
  sorted_keys = parameters.keys.sort
26
- string = EcalClient.configuration.secret.dup
26
+ string = @secret.dup
27
27
  string << sorted_keys.inject("") { |memo, key| memo << "#{key}#{parameters[key]}" }
28
28
  string << body.to_json if body
29
29
  Digest::MD5.hexdigest(string)
@@ -35,7 +35,7 @@ module EcalClient
35
35
 
36
36
  [:post, :get, :put].each do |method|
37
37
  define_method "#{method}_call" do |action, params, body, headers|
38
- params.merge!(apiKey: EcalClient.configuration.key)
38
+ params.merge!(apiKey: @key)
39
39
  connection.send("#{method}") do |req|
40
40
  req.url action, generate_params(params, body)
41
41
  req.body = body.to_json if body
@@ -3,9 +3,12 @@ module EcalClient
3
3
 
4
4
  class Unsupported < StandardError; end
5
5
 
6
- def initialize(endpoint, actions)
6
+ def initialize(endpoint, actions, options = {})
7
7
  @endpoint = endpoint
8
8
  @actions = actions
9
+ @key = options.delete(:key) || EcalClient.configuration.key
10
+ @secret = options.delete(:secret) || EcalClient.configuration.secret
11
+ EcalClient.configuration.options.merge!(options)
9
12
  end
10
13
 
11
14
  def get(options = {})
@@ -10,35 +10,31 @@ module EcalClient
10
10
  SUBSCRIBER = "/subscriber/".freeze
11
11
 
12
12
  def initialize(options = {})
13
- key = options.delete(:key)
14
- secret = options.delete(:secret)
15
- EcalClient.configuration.key = key if key
16
- EcalClient.configuration.secret = secret if secret
17
- EcalClient.configuration.options.merge!(options)
13
+ @options = options
18
14
  end
19
15
 
20
16
  def organisation
21
- @organisation ||= Rest.new(endpoint_for(ORGANISATION), [:get, :post, :put])
17
+ @organisation ||= Rest.new(endpoint_for(ORGANISATION), [:get, :post, :put], @options)
22
18
  end
23
19
 
24
20
  def publisher
25
- @publisher ||= Rest.new(endpoint_for(PUBLISHER), [:get, :put])
21
+ @publisher ||= Rest.new(endpoint_for(PUBLISHER), [:get, :put], @options)
26
22
  end
27
23
 
28
24
  def calendar
29
- @calendar ||= Rest.new(endpoint_for(CALENDAR), [:get, :post, :put])
25
+ @calendar ||= Rest.new(endpoint_for(CALENDAR), [:get, :post, :put], @options)
30
26
  end
31
27
 
32
28
  def event
33
- @event ||= Rest.new(endpoint_for(EVENT), [:get, :post, :put])
29
+ @event ||= Rest.new(endpoint_for(EVENT), [:get, :post, :put], @options)
34
30
  end
35
31
 
36
32
  def subscription_widget
37
- @subscription_widget ||= Rest.new(endpoint_for(SUBSCRIPTION_WIDGET), [:get])
33
+ @subscription_widget ||= Rest.new(endpoint_for(SUBSCRIPTION_WIDGET), [:get], @options)
38
34
  end
39
35
 
40
36
  def subscriber
41
- @subscriber ||= Rest.new(endpoint_for(SUBSCRIBER), [:get, :post, :put])
37
+ @subscriber ||= Rest.new(endpoint_for(SUBSCRIBER), [:get, :post, :put], @options)
42
38
  end
43
39
 
44
40
  private
@@ -1,3 +1,3 @@
1
1
  module EcalClient
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecal_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Faizal Zakaria
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-04 00:00:00.000000000 Z
11
+ date: 2016-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler