billogram 0.3.1 → 0.3.2
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 +4 -4
- data/billogram.gemspec +5 -1
- data/lib/billogram/relation_builder.rb +3 -2
- data/lib/billogram/resource.rb +20 -9
- data/lib/billogram/resources/invoice.rb +41 -0
- data/lib/billogram/version.rb +1 -1
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b193d4a77f4f21492b156cc3d027e1ffbf1a92f
|
4
|
+
data.tar.gz: bfc58aea5e2e9525be4b204b9b6968feb287b40e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7b6e4ef5615f23cbfbc4420316ad9554d16ccdeaa4b5749a4a73352c3859b5b770ae40a1030670fe8e468213e807b9b7bdec042ba0aed4c4810bf6f79f66461e
|
7
|
+
data.tar.gz: 0051702ba396759d44ff41cc34364e6dde4fc41d2bb58dfde254a15808e5d21e65bdf44461c62ccd01656d9e040dc794696bd79e94ae5a9de5fe3fbddfe3bd28
|
data/billogram.gemspec
CHANGED
@@ -8,8 +8,9 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Billogram::VERSION
|
9
9
|
spec.authors = ["Mark Birman"]
|
10
10
|
spec.email = ["birmanmark@gmail.com"]
|
11
|
+
spec.description = %q{Simple ruby wrapper for Billogram API}
|
11
12
|
|
12
|
-
spec.summary =
|
13
|
+
spec.summary = "Ruby library providing access to Billogram API"
|
13
14
|
spec.homepage = "http://github.com/mbirman/billogram"
|
14
15
|
spec.license = "MIT"
|
15
16
|
|
@@ -18,10 +19,13 @@ Gem::Specification.new do |spec|
|
|
18
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
20
|
spec.require_paths = ["lib"]
|
20
21
|
|
22
|
+
spec.required_ruby_version = '~> 2.0'
|
23
|
+
|
21
24
|
spec.add_development_dependency "bundler", "~> 1.10"
|
22
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
26
|
spec.add_development_dependency "rspec", "~> 3.0"
|
24
27
|
spec.add_development_dependency "webmock", "~> 1.21"
|
25
28
|
spec.add_development_dependency "dotenv", "~> 2.0"
|
26
29
|
spec.add_dependency "httparty", "~> 0.13"
|
30
|
+
spec.add_dependency "activesupport", "~> 4.2"
|
27
31
|
end
|
@@ -16,7 +16,7 @@ module Billogram
|
|
16
16
|
private
|
17
17
|
|
18
18
|
def relation_class(relation_name)
|
19
|
-
|
19
|
+
"Billogram::#{relation_name.to_s.classify}".constantize
|
20
20
|
end
|
21
21
|
|
22
22
|
def relation_attributes(relation_name)
|
@@ -33,7 +33,8 @@ module Billogram
|
|
33
33
|
if type == :one
|
34
34
|
value = relation_class(name).new(attrs)
|
35
35
|
elsif type == :many
|
36
|
-
|
36
|
+
singular = name.to_s.singularize
|
37
|
+
value = attrs.map{|item| relation_class(singular).new(item) }
|
37
38
|
end
|
38
39
|
|
39
40
|
resource.public_send("#{name}=", value)
|
data/lib/billogram/resource.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "active_support/core_ext/string/inflections.rb"
|
2
|
+
|
1
3
|
module Billogram
|
2
4
|
class Resource
|
3
5
|
DEFAULT_OPTIONS = { page: 1, page_size: 50 }
|
@@ -9,28 +11,24 @@ module Billogram
|
|
9
11
|
|
10
12
|
def endpoint(value = nil)
|
11
13
|
@endpoint = value if value
|
12
|
-
@endpoint ||
|
14
|
+
@endpoint || name.demodulize.underscore.pluralize
|
13
15
|
end
|
14
16
|
|
15
17
|
def search(options = {})
|
16
18
|
query = DEFAULT_OPTIONS.merge(options)
|
17
|
-
|
18
|
-
build_objects(response)
|
19
|
+
perform_request("#{endpoint}", :get, query)
|
19
20
|
end
|
20
21
|
|
21
22
|
def fetch(id)
|
22
|
-
|
23
|
-
build_objects(response)
|
23
|
+
perform_request("#{endpoint}/#{id}", :get)
|
24
24
|
end
|
25
25
|
|
26
26
|
def create(attributes)
|
27
|
-
|
28
|
-
build_objects(response)
|
27
|
+
perform_request("#{endpoint}", :post, attributes)
|
29
28
|
end
|
30
29
|
|
31
30
|
def update(id, attributes)
|
32
|
-
|
33
|
-
build_objects(response)
|
31
|
+
perform_request("#{endpoint}/#{id}", :put, attributes)
|
34
32
|
end
|
35
33
|
|
36
34
|
def delete(id)
|
@@ -49,6 +47,19 @@ module Billogram
|
|
49
47
|
else data
|
50
48
|
end
|
51
49
|
end
|
50
|
+
|
51
|
+
def perform_request(url, type, params = {})
|
52
|
+
case type
|
53
|
+
when :post, :put
|
54
|
+
query = { body: params.to_json }
|
55
|
+
when :get
|
56
|
+
query = { query: params }
|
57
|
+
else nil
|
58
|
+
end
|
59
|
+
|
60
|
+
response = Billogram.client.send(type, url, query)
|
61
|
+
build_objects(response) unless type == :delete
|
62
|
+
end
|
52
63
|
end
|
53
64
|
|
54
65
|
def initialize(attributes = {})
|
@@ -15,5 +15,46 @@ module Billogram
|
|
15
15
|
|
16
16
|
relation :items, :many
|
17
17
|
relation :events, :many
|
18
|
+
|
19
|
+
def sell
|
20
|
+
perform_request("#{endpoint}/#{id}/command/send", :post)
|
21
|
+
end
|
22
|
+
|
23
|
+
def collect
|
24
|
+
perform_request("#{endpoint}/#{id}/command/collect", :post)
|
25
|
+
end
|
26
|
+
|
27
|
+
def writeoff(options = {})
|
28
|
+
perform_request("#{endpoint}/#{id}/command/writeoff", :post)
|
29
|
+
end
|
30
|
+
|
31
|
+
def send!(options = {})
|
32
|
+
# https://billogram.com/api/documentation#billogram_call_send
|
33
|
+
perform_request("#{endpoint}/#{id}/command/send", :post, options)
|
34
|
+
end
|
35
|
+
|
36
|
+
def resend(options = {})
|
37
|
+
perform_request("#{endpoint}/#{id}/command/resend", :post, options)
|
38
|
+
end
|
39
|
+
|
40
|
+
def remind(options = {})
|
41
|
+
perform_request("#{endpoint}/#{id}/command/remind", :post, options)
|
42
|
+
end
|
43
|
+
|
44
|
+
def payment(options = {})
|
45
|
+
perform_request("#{endpoint}/#{id}/command/payment", :post, options)
|
46
|
+
end
|
47
|
+
|
48
|
+
def credit(options = {})
|
49
|
+
perform_request("#{endpoint}/#{id}/command/credit", :post, options)
|
50
|
+
end
|
51
|
+
|
52
|
+
def message(options = {})
|
53
|
+
perform_request("#{endpoint}/#{id}/command/message", :post, options)
|
54
|
+
end
|
55
|
+
|
56
|
+
def attach(options = {})
|
57
|
+
perform_request("#{endpoint}/#{id}/command/attach", :post, options)
|
58
|
+
end
|
18
59
|
end
|
19
60
|
end
|
data/lib/billogram/version.rb
CHANGED
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.
|
4
|
+
version: 0.3.2
|
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-
|
11
|
+
date: 2015-08-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,7 +94,21 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0.13'
|
97
|
-
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: activesupport
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '4.2'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '4.2'
|
111
|
+
description: Simple ruby wrapper for Billogram API
|
98
112
|
email:
|
99
113
|
- birmanmark@gmail.com
|
100
114
|
executables: []
|
@@ -140,9 +154,9 @@ require_paths:
|
|
140
154
|
- lib
|
141
155
|
required_ruby_version: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
|
-
- - "
|
157
|
+
- - "~>"
|
144
158
|
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
159
|
+
version: '2.0'
|
146
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
147
161
|
requirements:
|
148
162
|
- - ">="
|
@@ -153,5 +167,5 @@ rubyforge_project:
|
|
153
167
|
rubygems_version: 2.4.8
|
154
168
|
signing_key:
|
155
169
|
specification_version: 4
|
156
|
-
summary:
|
170
|
+
summary: Ruby library providing access to Billogram API
|
157
171
|
test_files: []
|