forte_ruby 0.1.1
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 +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +92 -0
- data/Rakefile +2 -0
- data/forte_ruby.gemspec +30 -0
- data/lib/forte_ruby/api/base.rb +52 -0
- data/lib/forte_ruby/api/object.rb +52 -0
- data/lib/forte_ruby/api/objects.rb +51 -0
- data/lib/forte_ruby/api/request_data.rb +45 -0
- data/lib/forte_ruby/resourses/address.rb +27 -0
- data/lib/forte_ruby/resourses/addresses.rb +22 -0
- data/lib/forte_ruby/resourses/customer.rb +29 -0
- data/lib/forte_ruby/resourses/customers.rb +16 -0
- data/lib/forte_ruby/resourses/settlement.rb +43 -0
- data/lib/forte_ruby/resourses/settlements.rb +16 -0
- data/lib/forte_ruby/resourses/transaction.rb +34 -0
- data/lib/forte_ruby/resourses/transactions.rb +16 -0
- data/lib/forte_ruby/version.rb +3 -0
- data/lib/forte_ruby.rb +27 -0
- data/spec/cassettes/address/create/error.yml +59 -0
- data/spec/cassettes/address/create/success.yml +52 -0
- data/spec/cassettes/address/delete/success.yml +50 -0
- data/spec/cassettes/addresses/empty.yml +50 -0
- data/spec/cassettes/addresses/many.yml +51 -0
- data/spec/cassettes/customer/create/error.yml +56 -0
- data/spec/cassettes/customer/create/success.yml +52 -0
- data/spec/cassettes/customer/delete/success.yml +50 -0
- data/spec/cassettes/customer/update/error.yml +59 -0
- data/spec/cassettes/customer/update/success.yml +52 -0
- data/spec/cassettes/customers/all/empty.yml +50 -0
- data/spec/cassettes/customers/all/many.yml +51 -0
- data/spec/cassettes/customers/filter/do_not_exist.yml +50 -0
- data/spec/cassettes/customers/filter/exist.yml +51 -0
- data/spec/cassettes/customers/find_by_id/does_not_exist.yml +53 -0
- data/spec/cassettes/customers/find_by_id/exists.yml +50 -0
- data/spec/cassettes/settlements/empty.yml +50 -0
- data/spec/cassettes/settlements/many.yml +50 -0
- data/spec/cassettes/transactions/empty.yml +50 -0
- data/spec/cassettes/transactions/many.yml +51 -0
- data/spec/config/forte_ruby.yml +6 -0
- data/spec/forte_ruby/api/base_spec.rb +24 -0
- data/spec/forte_ruby/api/object_spec.rb +90 -0
- data/spec/forte_ruby/api/objects_spec.rb +88 -0
- data/spec/forte_ruby/api/request_data_spec.rb +33 -0
- data/spec/forte_ruby/resourses/address_spec.rb +100 -0
- data/spec/forte_ruby/resourses/addresses_spec.rb +30 -0
- data/spec/forte_ruby/resourses/customer_spec.rb +90 -0
- data/spec/forte_ruby/resourses/customers_spec.rb +53 -0
- data/spec/forte_ruby/resourses/settlements_spec.rb +25 -0
- data/spec/forte_ruby/resourses/transactions_spec.rb +25 -0
- data/spec/spec_helper.rb +19 -0
- data/tasks/rspec.rake +3 -0
- metadata +241 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 852a87ffd6c62de4916270db40bb58788fbbf071
|
4
|
+
data.tar.gz: 9440db96d8fcdddf7bfee5162cf6239366f00da3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 81c932956a076d805de8aed7788f07e1a5c1961af6cb45a5d617ff05bf8d3f69d49e149f59ff26570893ca06b573e2a45fa2797b87368dd05ecdd0d1fe1d0170
|
7
|
+
data.tar.gz: 2ccf18cc2ff9d0def6411d2e5e9efb3150e105a20285b6a65a30c600c624a05012fdb971147ce95e86881df5c4d01949daaa291dab5489ae7166058421c6972e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Ruslan Milevskiy
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
# ForteRuby
|
2
|
+
|
3
|
+
The ForteRuby provides Ruby APIs for customers, addresses, settlements and transactions resourses using the Forte API.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'forte_ruby'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install forte_ruby
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Create a configuration file(`config/forte_ruby.yml`):
|
24
|
+
|
25
|
+
```yaml
|
26
|
+
development: &default
|
27
|
+
api_login_id: your_login_id
|
28
|
+
secure_transaction_key: you_key
|
29
|
+
account_id: your_account_id
|
30
|
+
location_id: you_location_id
|
31
|
+
endpoint: https://sandbox.forte.net/api/v1
|
32
|
+
|
33
|
+
test:
|
34
|
+
<<: *default
|
35
|
+
|
36
|
+
production:
|
37
|
+
api_login_id: your_login_id
|
38
|
+
secure_transaction_key: you_key
|
39
|
+
account_id: your_account_id
|
40
|
+
location_id: you_location_id
|
41
|
+
endpoint: https://forte.net/api/v1
|
42
|
+
```
|
43
|
+
|
44
|
+
Get customers list
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
ForteRuby.customers.all
|
48
|
+
```
|
49
|
+
|
50
|
+
Update/delete customer
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
customer = ForteRuby.customers.all.first
|
54
|
+
customer.update(first_name: 'Bob')
|
55
|
+
customer.delete
|
56
|
+
```
|
57
|
+
|
58
|
+
Create new customer
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
customer = ForteRuby.customers.build_from(first_name: 'Bob')
|
62
|
+
customer.save
|
63
|
+
```
|
64
|
+
|
65
|
+
Find customer by id
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
ForteRuby.customers.find_by_id('cst_123')
|
69
|
+
```
|
70
|
+
|
71
|
+
Use filters to get customers
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
ForteRuby.customers.filter(first_name: 'Bob')
|
75
|
+
```
|
76
|
+
|
77
|
+
Get addresses list
|
78
|
+
|
79
|
+
```ruby
|
80
|
+
customer = ForteRuby.customers.all.first
|
81
|
+
addresses = customer.addresses.all
|
82
|
+
```
|
83
|
+
|
84
|
+
You can use the same methods for transactions and settlements. But this gem provide only read operations for them.
|
85
|
+
|
86
|
+
## Contributing
|
87
|
+
|
88
|
+
1. Fork it ( https://github.com/[my-github-username]/forte_ruby/fork )
|
89
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
90
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
91
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
92
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/forte_ruby.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'forte_ruby/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "forte_ruby"
|
8
|
+
spec.version = ForteRuby::VERSION
|
9
|
+
spec.authors = ["Ruslan Milevskiy"]
|
10
|
+
spec.email = ["rpmilevskiy@gmail.com"]
|
11
|
+
spec.summary = %q{Ruby gem for Forte API}
|
12
|
+
spec.description = ""
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'rest-client'
|
22
|
+
spec.add_dependency 'resultable'
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency 'rspec'
|
27
|
+
spec.add_development_dependency 'vcr'
|
28
|
+
spec.add_development_dependency 'webmock'
|
29
|
+
spec.add_development_dependency 'pry'
|
30
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require "base64"
|
2
|
+
require "resultable"
|
3
|
+
require "ostruct"
|
4
|
+
require "yaml"
|
5
|
+
require 'rest-client'
|
6
|
+
|
7
|
+
module ForteRuby
|
8
|
+
module API
|
9
|
+
class Base
|
10
|
+
include Resultable
|
11
|
+
|
12
|
+
attr_accessor :request_data
|
13
|
+
|
14
|
+
def initialize(params = {})
|
15
|
+
set_attributes(params)
|
16
|
+
self.request_data ||= RequestData.new
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def send_request(url, method, params = nil)
|
22
|
+
self.result = Result.new
|
23
|
+
|
24
|
+
unless request_data.config
|
25
|
+
result.error = 'Provide configs in forte_ruby.yml file'
|
26
|
+
return result
|
27
|
+
end
|
28
|
+
|
29
|
+
params = params ? JSON.generate(params) : nil
|
30
|
+
begin
|
31
|
+
response = RestClient.send(method, url, *[params, request_data.headers].compact)
|
32
|
+
result.successful!
|
33
|
+
if block_given?
|
34
|
+
yield(response)
|
35
|
+
else
|
36
|
+
result.response = JSON.parse(response)
|
37
|
+
end
|
38
|
+
rescue RestClient::Exception => e
|
39
|
+
result.response = JSON.parse(e.response)['response']['response_desc']
|
40
|
+
end
|
41
|
+
|
42
|
+
result
|
43
|
+
end
|
44
|
+
|
45
|
+
def set_attributes(attributes)
|
46
|
+
attributes.each do |key, value|
|
47
|
+
self.send("#{key}=", value) if self.respond_to?(key)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module ForteRuby
|
2
|
+
module API
|
3
|
+
class Object < Base
|
4
|
+
|
5
|
+
attr_accessor :new
|
6
|
+
|
7
|
+
def delete
|
8
|
+
send_request(url, :delete)
|
9
|
+
end
|
10
|
+
|
11
|
+
def update(params)
|
12
|
+
set_attributes(params)
|
13
|
+
save
|
14
|
+
end
|
15
|
+
|
16
|
+
def save
|
17
|
+
method_name = new? ? :post : :put
|
18
|
+
|
19
|
+
result = send_request(url, method_name, api_attributes_hash)
|
20
|
+
|
21
|
+
if result.successful? && new?
|
22
|
+
set_attributes(result.response.merge(new: false))
|
23
|
+
end
|
24
|
+
|
25
|
+
result
|
26
|
+
end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
def url
|
31
|
+
raise 'Impelement it'
|
32
|
+
end
|
33
|
+
|
34
|
+
def api_attributes
|
35
|
+
raise 'Impelement it'
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def api_attributes_hash
|
41
|
+
api_attributes.inject({}) do |hash, element|
|
42
|
+
hash[element] = self.send(element)
|
43
|
+
hash
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def new?
|
48
|
+
new
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module ForteRuby
|
2
|
+
module API
|
3
|
+
class Objects < Base
|
4
|
+
def all
|
5
|
+
send_request(url, :get) do |response|
|
6
|
+
parse_response(response)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def build_from(params)
|
11
|
+
single_class.new(params.merge(request_data: request_data, new: true))
|
12
|
+
end
|
13
|
+
|
14
|
+
def find_by_id(id)
|
15
|
+
send_request(url + "/#{id}", :get) do |response|
|
16
|
+
parse_response(response)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def filter(params)
|
21
|
+
filter_value = params.map{ |key, value| "#{key}+eq+#{value}"}.join("+and+")
|
22
|
+
send_request(url + "?filter=#{filter_value}", :get) do |response|
|
23
|
+
parse_response(response)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def single_class
|
30
|
+
raise 'Impelement it'
|
31
|
+
end
|
32
|
+
|
33
|
+
def url
|
34
|
+
raise 'Impelement it'
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def parse_response(response)
|
40
|
+
parsed_response = JSON.parse(response)
|
41
|
+
if parsed_response['results']
|
42
|
+
self.result = parsed_response['results'].map do |object_params|
|
43
|
+
single_class.new(object_params.merge(request_data: request_data))
|
44
|
+
end
|
45
|
+
else
|
46
|
+
self.result = single_class.new(parsed_response)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module ForteRuby
|
2
|
+
module API
|
3
|
+
class RequestData
|
4
|
+
attr_accessor :config
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
self.config = parse_config_file
|
8
|
+
end
|
9
|
+
|
10
|
+
def base_url
|
11
|
+
"#{config.endpoint}/accounts/#{account_id}/locations/#{location_id}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def headers
|
15
|
+
{
|
16
|
+
'X-Forte-Auth-Account-Id' => account_id,
|
17
|
+
'Authorization' => "Basic #{signature}",
|
18
|
+
'Accept' => 'application/json',
|
19
|
+
'Content-Type' => 'json'
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def account_id
|
26
|
+
"act_#{config.account_id}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def location_id
|
30
|
+
"loc_#{config.location_id}"
|
31
|
+
end
|
32
|
+
|
33
|
+
def parse_config_file
|
34
|
+
file = Rails.root.join("config").join("forte_ruby.yml")
|
35
|
+
data = YAML.load(ERB.new(IO.read(file)).result)[Rails.env] rescue nil
|
36
|
+
data ? OpenStruct.new(data) : data
|
37
|
+
end
|
38
|
+
|
39
|
+
def signature
|
40
|
+
credentials = "#{config.api_login_id}:#{config.secure_transaction_key}"
|
41
|
+
Base64.encode64(credentials).gsub("\n", "")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ForteRuby
|
2
|
+
module Resourses
|
3
|
+
class Address < API::Object
|
4
|
+
|
5
|
+
API_ATTRIBUTES = [
|
6
|
+
:first_name, :last_name, :company_name, :phone, :fax, :email,
|
7
|
+
:label, :address_type, :shipping_address_type, :physical_address
|
8
|
+
]
|
9
|
+
|
10
|
+
API_ATTRIBUTES.each do |attribute|
|
11
|
+
attr_accessor attribute
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_accessor :customer_token, :address_token
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def url
|
19
|
+
"#{request_data.base_url}/customers/#{customer_token}/addresses/#{address_token}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def api_attributes
|
23
|
+
API_ATTRIBUTES
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module ForteRuby
|
2
|
+
module Resourses
|
3
|
+
class Addresses < API::Objects
|
4
|
+
|
5
|
+
attr_accessor :customer_token
|
6
|
+
|
7
|
+
def build_from(params)
|
8
|
+
single_class.new(params.merge(request_data: request_data, new: true, customer_token: customer_token))
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def single_class
|
14
|
+
Address
|
15
|
+
end
|
16
|
+
|
17
|
+
def url
|
18
|
+
"#{request_data.base_url}/customers/#{customer_token}/addresses"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module ForteRuby
|
2
|
+
module Resourses
|
3
|
+
class Customer < API::Object
|
4
|
+
|
5
|
+
API_ATTRIBUTES = [
|
6
|
+
:customer_token, :customer_id, :default_paymethod_token, :default_billing_address_token, :default_shipping_address_token,
|
7
|
+
:status, :last_name, :first_name, :company_name, :paymethod
|
8
|
+
]
|
9
|
+
|
10
|
+
API_ATTRIBUTES.each do |attribute|
|
11
|
+
attr_accessor attribute
|
12
|
+
end
|
13
|
+
|
14
|
+
def addresses
|
15
|
+
Addresses.new(request_data: request_data, customer_token: customer_token)
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def url
|
21
|
+
"#{request_data.base_url}/customers/#{customer_token}"
|
22
|
+
end
|
23
|
+
|
24
|
+
def api_attributes
|
25
|
+
API_ATTRIBUTES
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module ForteRuby
|
2
|
+
module Resourses
|
3
|
+
class Settlement < API::Object
|
4
|
+
|
5
|
+
API_ATTRIBUTES = [
|
6
|
+
:customer_token, :customer_id, :order_number, :reference_id, :settle_id, :transaction_id, :settle_date, :settle_type,
|
7
|
+
:settle_response_code, :settle_amount, :method
|
8
|
+
]
|
9
|
+
|
10
|
+
API_ATTRIBUTES.each do |attribute|
|
11
|
+
attr_accessor attribute
|
12
|
+
end
|
13
|
+
|
14
|
+
COMPLETED_RESPONSE_CODE = 'A01'
|
15
|
+
|
16
|
+
def delete
|
17
|
+
raise 'It is not implemented'
|
18
|
+
end
|
19
|
+
|
20
|
+
def update
|
21
|
+
raise 'It is not implemented'
|
22
|
+
end
|
23
|
+
|
24
|
+
def save
|
25
|
+
raise 'It is not implemented'
|
26
|
+
end
|
27
|
+
|
28
|
+
def status
|
29
|
+
if response_code == COMPLETED_RESPONSE_CODE
|
30
|
+
'completed'
|
31
|
+
else
|
32
|
+
'declined'
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
|
38
|
+
def api_attributes
|
39
|
+
API_ATTRIBUTES
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module ForteRuby
|
2
|
+
module Resourses
|
3
|
+
class Transaction < API::Object
|
4
|
+
|
5
|
+
API_ATTRIBUTES = [
|
6
|
+
:action, :one_time_token, :customer_token, :customer_id, :paymethod_token, :reference_id, :authorization_amount, :order_number,
|
7
|
+
:original_transaction_id, :transaction_id, :authorization_code, :software_name, :entered_by, :received_date, :origination_date,
|
8
|
+
:customer_accounting_code, :sales_tax_amount, :service_fee_amount, :sec_code, :billing_address, :shipping_address, :paymethod
|
9
|
+
]
|
10
|
+
|
11
|
+
API_ATTRIBUTES.each do |attribute|
|
12
|
+
attr_accessor attribute
|
13
|
+
end
|
14
|
+
|
15
|
+
def delete
|
16
|
+
raise 'It is not implemented'
|
17
|
+
end
|
18
|
+
|
19
|
+
def update
|
20
|
+
raise 'It is not implemented'
|
21
|
+
end
|
22
|
+
|
23
|
+
def save
|
24
|
+
raise 'It is not implemented'
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
def api_attributes
|
30
|
+
API_ATTRIBUTES
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/forte_ruby.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "forte_ruby/version"
|
2
|
+
require "forte_ruby/api/base"
|
3
|
+
require "forte_ruby/api/objects"
|
4
|
+
require "forte_ruby/api/object"
|
5
|
+
require "forte_ruby/api/request_data"
|
6
|
+
require "forte_ruby/resourses/customers"
|
7
|
+
require "forte_ruby/resourses/customer"
|
8
|
+
require "forte_ruby/resourses/addresses"
|
9
|
+
require "forte_ruby/resourses/address"
|
10
|
+
require "forte_ruby/resourses/transactions"
|
11
|
+
require "forte_ruby/resourses/transaction"
|
12
|
+
require "forte_ruby/resourses/settlements"
|
13
|
+
require "forte_ruby/resourses/settlement"
|
14
|
+
|
15
|
+
module ForteRuby
|
16
|
+
def self.customers
|
17
|
+
ForteRuby::Resourses::Customers.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.transactions
|
21
|
+
ForteRuby::Resourses::Transactions.new
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.settlements
|
25
|
+
ForteRuby::Resourses::Settlements.new
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://c2wL3J074JUdaU5k07HQ6m4BcPpeAY1m:c3wojAimKJ8MVEPYjCVl2qvzjczxXDbe@sandbox.forte.net/api/v1/accounts/act_300044/locations/loc_169531/customers/cst_5I5j8RuSCU6kmt3_miCtZQ/addresses/
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"first_name":null,"last_name":null,"company_name":null,"phone":null,"fax":null,"email":null,"label":null,"address_type":"unexisted","shipping_address_type":null,"physical_address":null}'
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip, deflate
|
14
|
+
X-Forte-Auth-Account-Id:
|
15
|
+
- act_300044
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
Content-Length:
|
19
|
+
- '186'
|
20
|
+
User-Agent:
|
21
|
+
- Ruby
|
22
|
+
response:
|
23
|
+
status:
|
24
|
+
code: 400
|
25
|
+
message: Bad Request
|
26
|
+
headers:
|
27
|
+
Server:
|
28
|
+
- Microsoft-IIS/7.5
|
29
|
+
Www-Authenticate:
|
30
|
+
- Basic realm="sandbox.forte.net"
|
31
|
+
X-Aspnet-Version:
|
32
|
+
- 4.0.30319
|
33
|
+
Cache-Control:
|
34
|
+
- no-cache
|
35
|
+
Content-Type:
|
36
|
+
- application/json; charset=utf-8
|
37
|
+
Date:
|
38
|
+
- Tue, 17 Mar 2015 15:37:19 GMT
|
39
|
+
Expires:
|
40
|
+
- "-1"
|
41
|
+
Pragma:
|
42
|
+
- no-cache
|
43
|
+
Connection:
|
44
|
+
- close
|
45
|
+
Set-Cookie:
|
46
|
+
- X-Mapping-gbooldlg=0DBF2E22300A61A18D35B33164C4A32E;path=/
|
47
|
+
X-Powered-By:
|
48
|
+
- ASP.NET
|
49
|
+
Content-Length:
|
50
|
+
- '325'
|
51
|
+
body:
|
52
|
+
encoding: UTF-8
|
53
|
+
string: '{"response":{"response_desc":"Error[1]: The content in the request
|
54
|
+
produced errors while parsing. Check that the content is correctly formatted
|
55
|
+
for the Content-Type provided. Error[2]: Unexpected value for AddressType
|
56
|
+
Error[3]: Error location: ,\"shipping_address_type\":null,\"physical_address\":n","environment":"sandbox"}}'
|
57
|
+
http_version:
|
58
|
+
recorded_at: Tue, 17 Mar 2015 15:37:19 GMT
|
59
|
+
recorded_with: VCR 2.9.3
|