billogram 0.3.3 → 0.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28175c88210eb4bea7941b3551b3c6c803314f84
4
- data.tar.gz: a521595d171976498014f511fe79f93b412803a6
3
+ metadata.gz: fadd6213aa124ee984518313a5e6efa9ab69f850
4
+ data.tar.gz: 6cd8a165334d0caf5e4759cf5d9b62c253e3f81b
5
5
  SHA512:
6
- metadata.gz: dc4717b36e5cfa137d8f64949de4bba7371d9c949d31f30b99001704d08c6b54b321a568df9e5d41dbf5f446549c684826a876613794a9abd7adc0330179f4e8
7
- data.tar.gz: f2a7b61addbba7ba172532d9c3a9c3ebe52786e34ef0bd2826346725f6d443d622d5acc66ca8d3f0a87759491de467df46173a880a01312a745b30298899c0bc
6
+ metadata.gz: 53acd31be13d777e960e46251a18956e761b2adbafe6b54006d3864bf167e066196f3f0eefe2364111b3361fe6cb602411068b5c24b3b0f1135576f6f93f02ec
7
+ data.tar.gz: ce5f2603f091d041eef0d964950a75108df450007f125ceac60bacae81282340dfa41570008ab1f992c199c1693d196e7e658375d016bba68f8fde6ee44f1d94
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "bundler", "~> 1.10"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "rspec-its"
27
28
  spec.add_development_dependency "webmock", "~> 1.21"
28
29
  spec.add_development_dependency "dotenv", "~> 2.0"
29
30
  spec.add_dependency "httparty", "~> 0.13"
@@ -17,6 +17,8 @@ require 'billogram/resources/item'
17
17
  require 'billogram/resources/regional_sweden'
18
18
  require "billogram/version"
19
19
 
20
+ require "billogram/inflections"
21
+
20
22
  module Billogram
21
23
  class << self
22
24
  attr_accessor :username, :password, :base_uri
@@ -0,0 +1,3 @@
1
+ ActiveSupport::Inflector.inflections do |inflect|
2
+ inflect.irregular 'data', 'data'
3
+ end
@@ -16,8 +16,7 @@ module Billogram
16
16
  private
17
17
 
18
18
  def relation_class(relation_name)
19
- class_name = relation_name == :data ? "Data" : relation_name.to_s.classify
20
- "Billogram::#{class_name}".constantize
19
+ "Billogram::#{relation_name.to_s.classify}".constantize
21
20
  end
22
21
 
23
22
  def relation_attributes(relation_name)
@@ -77,5 +77,13 @@ module Billogram
77
77
  def delete
78
78
  self.class.delete(id)
79
79
  end
80
+
81
+ def perform_request(*args)
82
+ self.class.perform_request(*args)
83
+ end
84
+
85
+ def endpoint
86
+ self.class.endpoint
87
+ end
80
88
  end
81
89
  end
@@ -1,5 +1,7 @@
1
1
  module Billogram
2
2
  class Customer < Resource
3
+ endpoint 'customer'
4
+
3
5
  attr_accessor :customer_no, :name, :notes, :org_no, :vat_no, :created_at, :updated_at, :company_type
4
6
 
5
7
  relation :address, :one
@@ -17,44 +17,49 @@ module Billogram
17
17
  relation :events, :many
18
18
 
19
19
  def sell
20
- perform_request("#{endpoint}/#{id}/command/send", :post)
20
+ perform_request(command_path(:sell), :post)
21
21
  end
22
22
 
23
23
  def collect
24
- perform_request("#{endpoint}/#{id}/command/collect", :post)
24
+ perform_request(command_path(:collect), :post)
25
25
  end
26
26
 
27
- def writeoff(options = {})
28
- perform_request("#{endpoint}/#{id}/command/writeoff", :post)
27
+ def writeoff
28
+ perform_request(command_path(:writeoff), :post)
29
29
  end
30
30
 
31
- def send!(options = {})
32
- # https://billogram.com/api/documentation#billogram_call_send
33
- perform_request("#{endpoint}/#{id}/command/send", :post, options)
31
+ def send!(method: )
32
+ perform_request(command_path(:send), :post, {method: method})
34
33
  end
35
34
 
36
- def resend(options = {})
37
- perform_request("#{endpoint}/#{id}/command/resend", :post, options)
35
+ def resend(method: )
36
+ perform_request(command_path(:resend), :post, {method: method})
38
37
  end
39
38
 
40
- def remind(options = {})
41
- perform_request("#{endpoint}/#{id}/command/remind", :post, options)
39
+ def remind(method: )
40
+ perform_request(command_path(:remind), :post, {method: method})
42
41
  end
43
42
 
44
- def payment(options = {})
45
- perform_request("#{endpoint}/#{id}/command/payment", :post, options)
43
+ def payment(amount: )
44
+ perform_request(command_path(:payment), :post, {amount: amount})
46
45
  end
47
46
 
48
47
  def credit(options = {})
49
- perform_request("#{endpoint}/#{id}/command/credit", :post, options)
48
+ perform_request(command_path(:credit), :post, options)
50
49
  end
51
50
 
52
- def message(options = {})
53
- perform_request("#{endpoint}/#{id}/command/message", :post, options)
51
+ def message(message: )
52
+ perform_request(command_path(:message), :post, {message: message})
54
53
  end
55
54
 
56
55
  def attach(options = {})
57
- perform_request("#{endpoint}/#{id}/command/attach", :post, options)
56
+ perform_request(command_path(:attach), :post, options)
57
+ end
58
+
59
+ private
60
+
61
+ def command_path(command)
62
+ "#{endpoint}/#{id}/command/#{command}"
58
63
  end
59
64
  end
60
65
  end
@@ -1,3 +1,3 @@
1
1
  module Billogram
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: billogram
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Birman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-28 00:00:00.000000000 Z
11
+ date: 2015-08-31 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.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-its
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: webmock
57
71
  requirement: !ruby/object:Gem::Requirement
@@ -129,6 +143,7 @@ files:
129
143
  - lib/billogram.rb
130
144
  - lib/billogram/client.rb
131
145
  - lib/billogram/error.rb
146
+ - lib/billogram/inflections.rb
132
147
  - lib/billogram/relation_builder.rb
133
148
  - lib/billogram/resource.rb
134
149
  - lib/billogram/resources/address.rb