chartmogul_client 0.0.4 → 0.0.5

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: 26dbce9ba7e2cad8f4a591db47a9d92a537818fc
4
- data.tar.gz: 18ecd770d6a39e4441cf37b3cd2920396e21ee38
3
+ metadata.gz: 4d3514e05aa72ec9a5d2251c19a503d86ab1ef7f
4
+ data.tar.gz: 0d7bf78b1e84be2afa2b78d2e3096526725f144b
5
5
  SHA512:
6
- metadata.gz: f0c257273385233e62fc4c34913c3af5589313de92f38dfa665aea0fd1562c30a8c452893c3ea75be33b213ecda0ae20f55495d5149e619a1c5dbed1ecc8d60d
7
- data.tar.gz: 3d81ecf17a60bfd5dd55a24e4ce81211efc12873054436e0377f8c4bde0efd8e64d54de7396b68202ffe137f96686fea5f12915f2f5b5c08e7996d476ffbf2ef
6
+ metadata.gz: f2a27ab33c707f28726000353e49c348b45483338664891f4edc3ac9dc2b1866be3fe0f4811a7a451fa7a034e8ba0192be33d49fec75769d6d34e778b97fa2b9
7
+ data.tar.gz: 221886e3db97ae1f19446956cd4a7362a1e2f1046f3b591e7b20e8c56476e863aa756be5d54dd6c3afc573526fbe956f2b81cc4325db95f0ff438c5ce35aa9b6
@@ -29,8 +29,7 @@ module Chartmogul
29
29
  # Returns the instance of Chartmogul::V1::Request.
30
30
  def create(customer_id, attributes = [])
31
31
  Chartmogul::V1::Request.new("#{BASE_URI}/#{customer_id}/attributes/custom",
32
- body: MultiJson.dump(custom: attributes),
33
- headers: { 'Content-Type' => 'application/json' },
32
+ body: { custom: attributes },
34
33
  method: :post,
35
34
  userpwd: client.userpwd,
36
35
  )
@@ -54,8 +53,7 @@ module Chartmogul
54
53
  # Returns the instance of Chartmogul::V1::Request.
55
54
  def update(customer_id, attributes = [])
56
55
  Chartmogul::V1::Request.new("#{BASE_URI}/#{customer_id}/attributes/custom",
57
- body: MultiJson.dump(custom: attributes),
58
- headers: { 'Content-Type' => 'application/json' },
56
+ body: { custom: attributes },
59
57
  method: :put,
60
58
  userpwd: client.userpwd,
61
59
  )
@@ -10,8 +10,16 @@ module Chartmogul
10
10
  Chartmogul::V1::Import::Customers.new(client)
11
11
  end
12
12
 
13
+ # Public: Get plans API.
14
+ #
15
+ # Returns the instance of Chartmogul::V1::Import::Plans.
16
+ def plans
17
+ Chartmogul::V1::Import::Plans.new(client)
18
+ end
19
+
13
20
  end
14
21
  end
15
22
  end
16
23
 
17
24
  require 'chartmogul/v1/import/customers'
25
+ require 'chartmogul/v1/import/plans'
@@ -34,8 +34,8 @@ module Chartmogul
34
34
  # :zip - The String zip code of the customer's location (optional).
35
35
  #
36
36
  # Returns the instance of Chartmogul::V1::Request.
37
- def create(**options)
38
- Chartmogul::V1::Request.new "#{BASE_URI}", options.merge(method: :post, userpwd: client.userpwd)
37
+ def create(options = {})
38
+ Chartmogul::V1::Request.new BASE_URI, options.merge(method: :post, userpwd: client.userpwd)
39
39
  end
40
40
 
41
41
  # Public: Get list Customers.
@@ -44,7 +44,7 @@ module Chartmogul
44
44
  #
45
45
  # Returns the instance of Chartmogul::V1::Request.
46
46
  def list
47
- Chartmogul::V1::Request.new "#{BASE_URI}", userpwd: client.userpwd
47
+ Chartmogul::V1::Request.new BASE_URI, userpwd: client.userpwd
48
48
  end
49
49
  end
50
50
  end
@@ -55,8 +55,7 @@ module Chartmogul
55
55
  # Returns the instance of Chartmogul::V1::Request.
56
56
  def create(customer_id, invoices = [])
57
57
  Chartmogul::V1::Request.new("#{BASE_URI}/#{customer_id}/invoices",
58
- body: MultiJson.dump(invoices: invoices),
59
- headers: { 'Content-Type' => 'application/json' },
58
+ body: { invoices: invoices },
60
59
  method: :post,
61
60
  userpwd: client.userpwd,
62
61
  )
@@ -0,0 +1,31 @@
1
+ module Chartmogul
2
+ module V1
3
+ class Import::Plans < Chartmogul::V1::Base
4
+ BASE_URI = "#{BASE_URI}/import/plans"
5
+
6
+ # Public: Import a Plan.
7
+ #
8
+ # See: https://dev.chartmogul.com/docs/import-plan
9
+ #
10
+ # options - The Hash options used to create a Plan (default: {}).
11
+ #
12
+ # Returns the instance of Chartmogul::V1::Request.
13
+ def create(options = {})
14
+ Chartmogul::V1::Request.new(BASE_URI,
15
+ body: options,
16
+ method: :post,
17
+ userpwd: client.userpwd,
18
+ )
19
+ end
20
+
21
+ # Public: Get list Plans.
22
+ #
23
+ # See: https://dev.chartmogul.com/docs/list-all-imported-plans
24
+ #
25
+ # Returns the instance of Chartmogul::V1::Request.
26
+ def list
27
+ Chartmogul::V1::Request.new BASE_URI, userpwd: client.userpwd
28
+ end
29
+ end
30
+ end
31
+ end
@@ -10,15 +10,21 @@ module Chartmogul
10
10
  # Public: Constructor.
11
11
  #
12
12
  # url - The String url.
13
- # body - The String body.
14
- # headers - The Hash headers.
13
+ # body - The String body (default: nil).
14
+ # headers - The Hash headers (default: {}).
15
15
  # method - The Symbol request method (default: :get).
16
- # userpwd - The String with credentials for Basic Authentication.
17
- # params - The Hash query params.
18
- def initialize(url, body: nil, headers: nil, method: :get, userpwd: nil, **params)
19
- @url = url
20
- @userpwd = userpwd
21
- @params = params
16
+ # userpwd - The String with credentials for Basic Authentication (default: nil).
17
+ # params - The Hash query params (default: {}).
18
+ def initialize(url, body: nil, headers: {}, method: :get, userpwd: nil, **params)
19
+ @url = url
20
+ @userpwd = userpwd
21
+ @params = params
22
+
23
+ if body
24
+ body = MultiJson.dump(body)
25
+ headers.merge!('Content-Type' => 'application/json')
26
+ end
27
+
22
28
  @response = Typhoeus::Request.new(url,
23
29
  body: body,
24
30
  connecttimeout: 5,
@@ -1,5 +1,5 @@
1
1
  module Chartmogul
2
2
 
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
 
5
5
  end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Chartmogul::V1::Import::Plans do
4
+
5
+ let(:client) { Chartmogul::Client.new }
6
+
7
+ describe '#create' do
8
+ let(:url) { 'https://api.chartmogul.com/v1/import/plans' }
9
+ let(:body) { [ {foo: 'bar'} ] }
10
+ let(:query) { {} }
11
+
12
+ before do
13
+ stub_request(:post, url).with(body: body.to_json).to_return(status: 201)
14
+ end
15
+
16
+ subject { client.import.plans.create(body) }
17
+
18
+ it_should_behave_like 'a base ChartMogul API V1 requests', method: :post
19
+ end
20
+
21
+ describe '#list' do
22
+ let(:url) { 'https://api.chartmogul.com/v1/import/plans' }
23
+ let(:query) { { } }
24
+
25
+ before do
26
+ stub_request(:get, url).with(query: query).to_return(status: 200)
27
+ end
28
+
29
+ subject { client.import.plans.list }
30
+
31
+ it_should_behave_like 'a base ChartMogul API V1 requests'
32
+ end
33
+
34
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chartmogul_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexey Vokhmin
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-28 00:00:00.000000000 Z
12
+ date: 2016-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: typhoeus
@@ -117,6 +117,7 @@ files:
117
117
  - lib/chartmogul/v1/import.rb
118
118
  - lib/chartmogul/v1/import/customers.rb
119
119
  - lib/chartmogul/v1/import/invoices.rb
120
+ - lib/chartmogul/v1/import/plans.rb
120
121
  - lib/chartmogul/v1/request.rb
121
122
  - lib/chartmogul/version.rb
122
123
  - lib/chartmogul_client.rb
@@ -124,6 +125,7 @@ files:
124
125
  - spec/chartmogul/v1/customers_spec.rb
125
126
  - spec/chartmogul/v1/import/customers_spec.rb
126
127
  - spec/chartmogul/v1/import/invoices_spec.rb
128
+ - spec/chartmogul/v1/import/plans_spec.rb
127
129
  - spec/chartmogul/v1/import_spec.rb
128
130
  - spec/spec_helper.rb
129
131
  - spec/support/shared_examples/chartmogul_api_v1_examples.rb
@@ -156,6 +158,7 @@ test_files:
156
158
  - spec/chartmogul/v1/customers_spec.rb
157
159
  - spec/chartmogul/v1/import/customers_spec.rb
158
160
  - spec/chartmogul/v1/import/invoices_spec.rb
161
+ - spec/chartmogul/v1/import/plans_spec.rb
159
162
  - spec/chartmogul/v1/import_spec.rb
160
163
  - spec/spec_helper.rb
161
164
  - spec/support/shared_examples/chartmogul_api_v1_examples.rb