eventbrite_api_client 0.1.0 → 0.1.2

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: f0e0107cfb193a9558a87caea1090b082ff95951
4
- data.tar.gz: d5c66b4ebb98c326ea11f632b9568280372a7fa4
3
+ metadata.gz: 0a3efb18394e56de124d2e204a558f48e7502021
4
+ data.tar.gz: f2c25dfbde83c45ace53100a1f58e47e9403a77f
5
5
  SHA512:
6
- metadata.gz: 8c674da11e8ab18ba4a3453c1ac79859c8ac2fbea03e9f2d28ebd71eec36bec0662301aedbba3471251a9cb85fc93fca8888488538b16da9b3c9a5874760665e
7
- data.tar.gz: 1c91d8e589e0b16423e6a5619104f0732c537bff6597395d18da2eabc4bf0365d5b297dedf2e400ab0f84b55e7d1b28294f505193bfb8a7a9c544383b8d3a6e8
6
+ metadata.gz: fbb9209cd2d6a1b7582dd83f3e99f2f359c5cb4184f856a42eaa47e03334dc285a4685f02004bdedde04d05bc36e16ff7bee30a0182ec99dc52cf04bd7c1034f
7
+ data.tar.gz: fb3a2bb2d93a22f40ada4027a06ccee1d31c194bf23d0778cdca7070a10eced1be3c2bb782fc3555c048889239386a699b9faf878a1b41d4b9cd878e9b22ddb4
@@ -8,9 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.version = EventbriteApiClient::VERSION
9
9
  spec.authors = ["Kelly Price"]
10
10
  spec.email = ["kellyjosephprice@gmail.com"]
11
- spec.summary = %q{Eventbrite API Client}
12
- spec.description = %q{A simple interface for the Eventbrite API}
13
- spec.homepage = ""
11
+ spec.summary = %q{Eventbrite API v3 Client}
12
+ spec.description = %q{A simple interface for the Eventbrite API v3}
13
+ spec.homepage = "https://github.com/kellyjosephprice/eventbrite_api_client"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.5"
22
22
  spec.add_development_dependency "rake", "~> 10.4"
23
23
  spec.add_development_dependency "rspec", "~> 3.3"
24
+ spec.add_development_dependency "pry", "~> 0"
24
25
 
25
26
  spec.add_runtime_dependency "httparty", "~> 0"
26
27
  end
@@ -1,4 +1,6 @@
1
1
  require 'eventbrite_api_client/version'
2
+ require 'eventbrite_api_client/params'
3
+
2
4
  require 'httparty'
3
5
 
4
6
  class EventbriteApiClient
@@ -10,15 +12,16 @@ class EventbriteApiClient
10
12
  def initialize(options)
11
13
  self.class.headers 'Authorization' => "Bearer #{options[:auth_token]}"
12
14
 
15
+ @debug = options[:debug]
13
16
  @path = ""
14
17
  end
15
18
 
16
19
  def get(params = {})
17
- check_errors self.class.get(path, query: params)
20
+ wrap_request(params) { |path, querystring| self.class.get(path, querystring) }
18
21
  end
19
22
 
20
23
  def post(params = {})
21
- check_errors self.class.post(path, query: params)
24
+ wrap_request(params) { |path, querystring| self.class.post(path, querystring) }
22
25
  end
23
26
 
24
27
  def method_missing(method_sym, *args)
@@ -34,7 +37,9 @@ class EventbriteApiClient
34
37
  attr_writer :path
35
38
 
36
39
  private
37
- def check_errors(response)
40
+ attr_reader :debug
41
+
42
+ def ensure_json(response)
38
43
  if !is_json?(response)
39
44
  {
40
45
  'error' => 'NOT_FOUND',
@@ -50,4 +55,12 @@ class EventbriteApiClient
50
55
  response.respond_to?(:headers) &&
51
56
  response.headers['content-type'] == 'application/json'
52
57
  end
58
+
59
+ def wrap_request(params, &block)
60
+ _params = Params.new(params)
61
+
62
+ puts "#{path}#{_params.to_s}" if debug
63
+
64
+ ensure_json(block.call(path, query: _params.format))
65
+ end
53
66
  end
@@ -0,0 +1,20 @@
1
+ class EventbriteApiClient::Params
2
+ attr_accessor :data
3
+
4
+ def initialize(data = {})
5
+ @data = data
6
+ end
7
+
8
+ def format
9
+ data.update(data) { |k,v| format_datetime(v) }
10
+ end
11
+
12
+ def format_datetime(datetime)
13
+ return datetime unless datetime.is_a? Time
14
+ datetime.utc.strftime "%Y-%m-%d%H:%M:%SZ"
15
+ end
16
+
17
+ def to_s
18
+ "?".concat data.each.map { |k,v| "#{k}=#{v}" }.join("&")
19
+ end
20
+ end
@@ -1,3 +1,3 @@
1
1
  class EventbriteApiClient
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ describe EventbriteApiClient::Params do
4
+ subject(:params) { EventbriteApiClient::Params.new }
5
+
6
+ context 'methods' do
7
+ let(:datetime) { Time.at(0) }
8
+ let(:formatted_datetime) { "1970-01-0100:00:00Z" }
9
+
10
+ describe '#format' do
11
+ let(:hash) { { id: 1, start: datetime } }
12
+
13
+ before { params.data = hash }
14
+
15
+ it 'should update datetime values' do
16
+ expect(params.format)
17
+ .to eq( { id: 1, start: formatted_datetime } )
18
+ end
19
+ end
20
+
21
+ describe '#format_datetime' do
22
+ it 'should return a date as utc in the format YYYY-MM-DDThh:mm:ssZ' do
23
+ expect(params.format_datetime(datetime)).to eq(formatted_datetime)
24
+ end
25
+ end
26
+ end
27
+ end
data/spec/spec_helper.rb CHANGED
@@ -2,3 +2,5 @@ require 'bundler/setup'
2
2
  Bundler.setup
3
3
 
4
4
  require 'eventbrite_api_client'
5
+
6
+ require 'pry'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eventbrite_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelly Price
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-18 00:00:00.000000000 Z
11
+ date: 2015-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: httparty
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +80,7 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
- description: A simple interface for the Eventbrite API
83
+ description: A simple interface for the Eventbrite API v3
70
84
  email:
71
85
  - kellyjosephprice@gmail.com
72
86
  executables: []
@@ -81,12 +95,14 @@ files:
81
95
  - Rakefile
82
96
  - eventbrite_api_client.gemspec
83
97
  - lib/eventbrite_api_client.rb
98
+ - lib/eventbrite_api_client/params.rb
84
99
  - lib/eventbrite_api_client/version.rb
100
+ - spec/eventbrite_api_client_params_spec.rb
85
101
  - spec/eventbrite_api_client_spec.rb
86
102
  - spec/features/requests_spec.rb
87
103
  - spec/spec_helper.rb
88
104
  - tasks/rspec.rake
89
- homepage: ''
105
+ homepage: https://github.com/kellyjosephprice/eventbrite_api_client
90
106
  licenses:
91
107
  - MIT
92
108
  metadata: {}
@@ -106,11 +122,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
122
  version: '0'
107
123
  requirements: []
108
124
  rubyforge_project:
109
- rubygems_version: 2.4.5
125
+ rubygems_version: 2.2.2
110
126
  signing_key:
111
127
  specification_version: 4
112
- summary: Eventbrite API Client
128
+ summary: Eventbrite API v3 Client
113
129
  test_files:
130
+ - spec/eventbrite_api_client_params_spec.rb
114
131
  - spec/eventbrite_api_client_spec.rb
115
132
  - spec/features/requests_spec.rb
116
133
  - spec/spec_helper.rb