tito 0.1.1 → 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: 81a4b7c099aa967d4d0a19076fd138e9d5e90125
4
- data.tar.gz: 10985349811344d364f482768776109db3baf699
3
+ metadata.gz: bd8ca9fe94ea995499e3b1c204ff40313809eb59
4
+ data.tar.gz: bd442ad3ba07d49dfaa95996e3c5fe571498fd0d
5
5
  SHA512:
6
- metadata.gz: e2d146a52130a4024d4ab838239ccba2aae07d2557f1d9797a7f66d52623eedf66db24d32b5f6711de80437babf14f8209ffced4b091fd6243e7d90621056dca
7
- data.tar.gz: 3d88b7bb7fe7bafe2d6b07ae4ee6a6ba90fe650ae9510752ccc7c83fc2b3dcf8074144fefb9043cc7e1c948c8f13a6ca6ca0d6f5d54b31a45e3d36fea87d6e2c
6
+ metadata.gz: 0ab0f72cc9fc66873d6ab09c8f8c800006a2b109995bbab5f71a41175009c9e5d072fb968ea519dbec33536a26166eb1333f9f93db0ed41d88dd586a63069d6a
7
+ data.tar.gz: 50963475ff5ce2c15585dfe3c3062cdc2f1d159186faf23c8d1085ead52b9ebce1f4142c321c644cdc89b5cce5f642f30e3a70f5b496359e12749656486acee3
data/Gemfile CHANGED
@@ -6,4 +6,8 @@ gemspec
6
6
 
7
7
  group :development do
8
8
  gem 'byebug', require: 'byebug'
9
+ end
10
+
11
+ group :test do
12
+ gem 'm', '~> 1.3.1'
9
13
  end
data/lib/tito/account.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module Tito
2
2
  class Account < Base
3
3
  property :name, type: :string
4
+ property :slug, type: :string
4
5
 
5
6
  def events
6
7
  Tito::Event.where(account_id: id)
data/lib/tito/event.rb CHANGED
@@ -3,6 +3,19 @@ module Tito
3
3
  belongs_to :account
4
4
 
5
5
  property :title, type: :string
6
+ property :security_token, type: :string
7
+
8
+ def account_id
9
+ attributes['account_id'] || attributes['account-id']
10
+ end
11
+
12
+ def account_id=(val)
13
+ attributes['account_id'] = val
14
+ end
15
+
16
+ def security_token
17
+ attributes['security_token'] || attributes['security-token']
18
+ end
6
19
 
7
20
  class << self
8
21
 
@@ -19,26 +32,9 @@ module Tito
19
32
  parts << 'events'
20
33
  end
21
34
  File.join(*parts)
22
- # parts = ['%{account_id}', '%{id}']
23
- # if params
24
- # path_params = params.delete(:path) || params
25
- # parts.unshift(_prefix_path % path_params.symbolize_keys)
26
- # else
27
- # parts.unshift(_prefix_path)
28
- # end
29
- # parts.reject!{|part| part == "" }
30
- # File.join(*parts)
31
35
  rescue KeyError
32
36
  raise ArgumentError, "Please make sure to include account_id"
33
37
  end
34
-
35
- # def path(params=nil)
36
- # if params[:id].blank?
37
- # ['%account_id', 'events'].compact.join('/')
38
- # else
39
- # '%account_id'
40
- # end
41
- # end
42
38
  end
43
39
  end
44
40
  end
@@ -0,0 +1,32 @@
1
+ module Tito
2
+ module Eventable
3
+
4
+ def self.included(base)
5
+ base.extend ClassMethods
6
+ base.class_eval do
7
+ property :event
8
+ property :event_id
9
+ end
10
+ end
11
+
12
+ def event=(tito_event)
13
+ self.event_id = tito_event.id
14
+ self.attributes[:event] = tito_event
15
+ @event = tito_event
16
+ end
17
+
18
+ module ClassMethods
19
+ def path(params=nil)
20
+ prefix_path = '%{account_id}/%{event_id}'
21
+ path_params = params.delete(:path) || params
22
+ path_params[:event_id] = params[:event][:id]
23
+ path_params[:account_id] = params[:event][:account_id] || params[:event]['account-id']
24
+ parts = [].unshift(prefix_path % path_params.symbolize_keys)
25
+ parts << params[:type]
26
+ File.join(*parts)
27
+ rescue KeyError
28
+ raise ArgumentError, "Please make sure to include account_id and event_id"
29
+ end
30
+ end
31
+ end
32
+ end
@@ -13,7 +13,7 @@ module Tito
13
13
 
14
14
  if token.respond_to?(:empty?) && !token.empty?
15
15
  env[:url].query = build_query params
16
- env[:request_headers][AUTH_HEADER] ||= %(Token token="#{token}")
16
+ env[:request_headers][AUTH_HEADER] ||= %(Bearer #{token})
17
17
  end
18
18
 
19
19
  @app.call env
data/lib/tito/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Tito
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -1,8 +1,7 @@
1
1
  module Tito
2
2
  class WebhookEndpoint < Tito::Base
3
- belongs_to :event
3
+ include Eventable
4
4
 
5
- property :url, type: :string
6
- property :event_id, type: :int
5
+ property :url, type: :string
7
6
  end
8
7
  end
data/lib/tito.rb CHANGED
@@ -2,6 +2,7 @@ require 'json_api_client'
2
2
  require "tito/version"
3
3
  require "tito/base"
4
4
  require "tito/oauth2_middleware"
5
+ require "tito/eventable"
5
6
 
6
7
  require "tito/account"
7
8
  require "tito/event"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tito
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Campbell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-09 00:00:00.000000000 Z
11
+ date: 2016-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json_api_client
@@ -72,6 +72,7 @@ files:
72
72
  - lib/tito/account.rb
73
73
  - lib/tito/base.rb
74
74
  - lib/tito/event.rb
75
+ - lib/tito/eventable.rb
75
76
  - lib/tito/oauth2_middleware.rb
76
77
  - lib/tito/version.rb
77
78
  - lib/tito/webhook_endpoint.rb
@@ -97,9 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
98
  version: '0'
98
99
  requirements: []
99
100
  rubyforge_project:
100
- rubygems_version: 2.2.2
101
+ rubygems_version: 2.5.1
101
102
  signing_key:
102
103
  specification_version: 4
103
104
  summary: Consumer library for Tito API
104
105
  test_files: []
105
- has_rdoc: