vauchar_api 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 +12 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +67 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/active_resource/connection_ext.rb +20 -0
- data/lib/active_resource/custom_methods_ext.rb +11 -0
- data/lib/active_resource/formats_ext.rb +16 -0
- data/lib/vauchar_api/configuration.rb +8 -0
- data/lib/vauchar_api/connection.rb +38 -0
- data/lib/vauchar_api/resources/base.rb +53 -0
- data/lib/vauchar_api/resources/brand.rb +25 -0
- data/lib/vauchar_api/resources/customer.rb +33 -0
- data/lib/vauchar_api/resources/customer_deal.rb +57 -0
- data/lib/vauchar_api/resources/deal.rb +36 -0
- data/lib/vauchar_api/resources/list.rb +42 -0
- data/lib/vauchar_api/resources/verify_credentials.rb +5 -0
- data/lib/vauchar_api/resources.rb +2 -0
- data/lib/vauchar_api/version.rb +3 -0
- data/lib/vauchar_api.rb +19 -0
- data/vauchar_api.gemspec +29 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '0591d688bea72df334e2c414d9a31993ce37ef9ceb8870d5299c33cdca499022'
|
4
|
+
data.tar.gz: 60d4e3a42d4b35be233fab594e78843c132eace77112774b15e8acc658f503d8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a326a155354a834479f40880b210fb139efb5892e8bf90b30fed45dbdf02c7af2eb6908f868cb37a1f49d348a632af6e2d4d816c64e175c1918ec79b37d454e7
|
7
|
+
data.tar.gz: 970b8a1f6ee7ce02a55c718c891c09df020ddf86a62510734ba659b2b6f4f7740246d5fcb4bbeac6daedc1e764ebca5dc05d7dc53e702e02b761842c75adbfec
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
vauchar_api (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
activemodel (5.2.2)
|
10
|
+
activesupport (= 5.2.2)
|
11
|
+
activemodel-serializers-xml (1.0.2)
|
12
|
+
activemodel (> 5.x)
|
13
|
+
activesupport (> 5.x)
|
14
|
+
builder (~> 3.1)
|
15
|
+
activeresource (5.1.0)
|
16
|
+
activemodel (>= 5.0, < 7)
|
17
|
+
activemodel-serializers-xml (~> 1.0)
|
18
|
+
activesupport (>= 5.0, < 7)
|
19
|
+
activesupport (5.2.2)
|
20
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
21
|
+
i18n (>= 0.7, < 2)
|
22
|
+
minitest (~> 5.1)
|
23
|
+
tzinfo (~> 1.1)
|
24
|
+
builder (3.2.3)
|
25
|
+
concurrent-ruby (1.1.4)
|
26
|
+
diff-lcs (1.3)
|
27
|
+
httparty (0.16.4)
|
28
|
+
mime-types (~> 3.0)
|
29
|
+
multi_xml (>= 0.5.2)
|
30
|
+
i18n (1.5.3)
|
31
|
+
concurrent-ruby (~> 1.0)
|
32
|
+
mime-types (3.2.2)
|
33
|
+
mime-types-data (~> 3.2015)
|
34
|
+
mime-types-data (3.2018.0812)
|
35
|
+
minitest (5.11.3)
|
36
|
+
multi_xml (0.6.0)
|
37
|
+
rake (10.5.0)
|
38
|
+
rspec (3.8.0)
|
39
|
+
rspec-core (~> 3.8.0)
|
40
|
+
rspec-expectations (~> 3.8.0)
|
41
|
+
rspec-mocks (~> 3.8.0)
|
42
|
+
rspec-core (3.8.0)
|
43
|
+
rspec-support (~> 3.8.0)
|
44
|
+
rspec-expectations (3.8.2)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.8.0)
|
47
|
+
rspec-mocks (3.8.0)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.8.0)
|
50
|
+
rspec-support (3.8.0)
|
51
|
+
thread_safe (0.3.6)
|
52
|
+
tzinfo (1.2.5)
|
53
|
+
thread_safe (~> 0.1)
|
54
|
+
|
55
|
+
PLATFORMS
|
56
|
+
ruby
|
57
|
+
|
58
|
+
DEPENDENCIES
|
59
|
+
activeresource
|
60
|
+
bundler (~> 1.16)
|
61
|
+
httparty
|
62
|
+
rake (~> 10.0)
|
63
|
+
rspec (~> 3.0)
|
64
|
+
vauchar_api!
|
65
|
+
|
66
|
+
BUNDLED WITH
|
67
|
+
1.16.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Max
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# VaucharAPI
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/vauchar_api`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'vauchar_api'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install vauchar_api
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/vauchar_api.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "vauchar_api"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "httparty"
|
2
|
+
require "vauchar_api/connection"
|
3
|
+
|
4
|
+
module ActiveResource
|
5
|
+
class Connection
|
6
|
+
attr_reader :response
|
7
|
+
|
8
|
+
prepend VaucharAPI::Connection::ResponseCapture
|
9
|
+
prepend VaucharAPI::Connection::RequestNotification
|
10
|
+
|
11
|
+
def delete_with_body(path, body = "", headers = {})
|
12
|
+
with_auth do
|
13
|
+
HTTParty.delete("#{site.scheme}://#{site.host}:#{site.port}#{path}", {
|
14
|
+
headers: build_request_headers(headers, :delete, self.site.merge(path)),
|
15
|
+
body: body,
|
16
|
+
})
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module ActiveResource
|
2
|
+
module CustomMethods
|
3
|
+
def delete(method_name, options = {}, body = nil)
|
4
|
+
if body.blank?
|
5
|
+
connection.delete(custom_method_element_url(method_name, options), self.class.headers)
|
6
|
+
else
|
7
|
+
connection.delete_with_body(custom_method_element_url(method_name, options), body, self.class.headers)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ActiveResource
|
2
|
+
module Formats
|
3
|
+
def self.remove_root(data)
|
4
|
+
data = data.with_indifferent_access
|
5
|
+
data = data.key?(:data) ? data[:data] : data
|
6
|
+
p "Formats==================================="
|
7
|
+
p data
|
8
|
+
p "=========================================="
|
9
|
+
if data.is_a?(Hash) && data.keys.size == 1 && data.values.first.is_a?(Enumerable)
|
10
|
+
data.values.first
|
11
|
+
else
|
12
|
+
data
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module VaucharAPI
|
2
|
+
class Connection < ActiveResource::Connection
|
3
|
+
attr_reader :response
|
4
|
+
|
5
|
+
module ResponseCapture
|
6
|
+
def handle_response(response)
|
7
|
+
@response = super
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
include ResponseCapture
|
12
|
+
|
13
|
+
module RequestNotification
|
14
|
+
def request(method, path, *arguments)
|
15
|
+
super.tap do |response|
|
16
|
+
notify_about_request(method, path, response, arguments)
|
17
|
+
end
|
18
|
+
rescue => e
|
19
|
+
notify_about_request(method, path, e.response, arguments) if e.respond_to?(:response)
|
20
|
+
raise
|
21
|
+
end
|
22
|
+
|
23
|
+
def notify_about_request(method, path, response, arguments)
|
24
|
+
p "RequestNotification======================="
|
25
|
+
ActiveSupport::Notifications.instrument("request.active_resource_detailed") do |payload|
|
26
|
+
payload[:method] = method
|
27
|
+
payload[:path] = path
|
28
|
+
payload[:response] = response
|
29
|
+
payload[:data] = arguments
|
30
|
+
p payload
|
31
|
+
end
|
32
|
+
p "=========================================="
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
include RequestNotification
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "vauchar_api/version"
|
2
|
+
|
3
|
+
module VaucharAPI
|
4
|
+
class Base < ActiveResource::Base
|
5
|
+
self.site = "https://api.vauchar.com"
|
6
|
+
self.include_format_in_path = false
|
7
|
+
self.include_root_in_json = false
|
8
|
+
|
9
|
+
def accepts_attributes; nil; end
|
10
|
+
|
11
|
+
def encode(options = {})
|
12
|
+
same = dup
|
13
|
+
p accepts_attributes
|
14
|
+
same.attributes = same.attributes.slice(*accepts_attributes) if (accepts_attributes)
|
15
|
+
same.send("to_#{self.class.format.extension}", options)
|
16
|
+
end
|
17
|
+
|
18
|
+
class << self
|
19
|
+
def user
|
20
|
+
Configuration.merchant_id
|
21
|
+
end
|
22
|
+
|
23
|
+
def password
|
24
|
+
Configuration.api_key
|
25
|
+
end
|
26
|
+
|
27
|
+
def init_prefix(resource)
|
28
|
+
init_prefix_explicit(resource.to_s.pluralize, "#{resource}_id")
|
29
|
+
end
|
30
|
+
|
31
|
+
def init_prefix_explicit(resource_type, resource_id)
|
32
|
+
self.prefix = "/#{resource_type}/:#{resource_id}/"
|
33
|
+
|
34
|
+
define_method resource_id.to_sym do
|
35
|
+
@prefix_options[resource_id]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def keep_prefix_options
|
43
|
+
prefix_options = @prefix_options
|
44
|
+
yield
|
45
|
+
@prefix_options = prefix_options
|
46
|
+
self
|
47
|
+
end
|
48
|
+
|
49
|
+
def only_id
|
50
|
+
encode(only: :id, include: [], methods: [])
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module VaucharAPI
|
2
|
+
# ==== Examples
|
3
|
+
# [Create]
|
4
|
+
# new_brand = VaucharAPI::Brand.new(name: "test by max", email: "max@gmail.com")
|
5
|
+
# new_brand.save
|
6
|
+
#
|
7
|
+
# [Read]
|
8
|
+
# brand = VaucharAPI::Brand.find("brn-15510817645c73a12406a95")
|
9
|
+
# brands = VaucharAPI::Brand.all
|
10
|
+
#
|
11
|
+
# [Update]
|
12
|
+
# brand = VaucharAPI::Brand.find("brn-15510817645c73a12406a95")
|
13
|
+
# brand.name = "test update"
|
14
|
+
# brand.save
|
15
|
+
#
|
16
|
+
# [Delete]
|
17
|
+
# brand = VaucharAPI::Brand.find("brn-15510817645c73a12406a95")
|
18
|
+
# brand.destroy
|
19
|
+
|
20
|
+
class Brand < Base
|
21
|
+
def accepts_attributes
|
22
|
+
[:name, :email]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module VaucharAPI
|
2
|
+
# ==== Examples
|
3
|
+
# [Create]
|
4
|
+
# new_customer = VaucharAPI::Customer.new({
|
5
|
+
# user_id: "12345",
|
6
|
+
# name: "max",
|
7
|
+
# email: "max@gmail.com",
|
8
|
+
# phone: "+886912345678",
|
9
|
+
# birthday: "1990-03-25",
|
10
|
+
# })
|
11
|
+
# new_customer.save
|
12
|
+
#
|
13
|
+
# [Read]
|
14
|
+
# customer = VaucharAPI::Customer.find("cust-15507323535c6e4c416c697")
|
15
|
+
# customers = VaucharAPI::Customer.all
|
16
|
+
#
|
17
|
+
# [Update]
|
18
|
+
# customer = VaucharAPI::Customer.find("cust-15507323535c6e4c416c697")
|
19
|
+
# customer.name = "test update"
|
20
|
+
# customer.save
|
21
|
+
#
|
22
|
+
# [Delete]
|
23
|
+
# customer = VaucharAPI::Customer.find("cust-15507323535c6e4c416c697")
|
24
|
+
# customer.destroy
|
25
|
+
|
26
|
+
class Customer < Base
|
27
|
+
def accepts_attributes
|
28
|
+
accepts = [:name, :email, :phone, :birthday, :created, :last_seen, :total_purchase]
|
29
|
+
accepts.push :user_id if self.new?
|
30
|
+
accepts
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module VaucharAPI
|
2
|
+
# ==== Examples
|
3
|
+
# [Read]
|
4
|
+
# deals = VaucharAPI::CustomerDeal.find(:all, params: {customer_id: "cust-15507323535c6e4c416c697"})
|
5
|
+
#
|
6
|
+
# [Redemptions]
|
7
|
+
# deals[1].redemptions
|
8
|
+
# deals[1].voucher.voucher_code # => "DA2C2J65JFVNY"
|
9
|
+
#
|
10
|
+
# [Validate]
|
11
|
+
# deals[1].validate
|
12
|
+
|
13
|
+
class CustomerDeal < Base
|
14
|
+
init_prefix :customer
|
15
|
+
self.collection_name = "deals"
|
16
|
+
|
17
|
+
def customer_id
|
18
|
+
@prefix_options[:customer_id]
|
19
|
+
end
|
20
|
+
|
21
|
+
def id
|
22
|
+
self.data.id
|
23
|
+
end
|
24
|
+
|
25
|
+
def redemptions
|
26
|
+
keep_prefix_options do
|
27
|
+
resource = post(:redemptions, {}, only_id)
|
28
|
+
data = self.class.format.decode(resource.body)
|
29
|
+
load({voucher: data}, false, true)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def validate
|
34
|
+
keep_prefix_options do
|
35
|
+
resource = get(:validate, {})
|
36
|
+
load({data: resource}, false, true)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# ==== Examples
|
41
|
+
# voucher = VaucharAPI::CustomerDeal.redemptions(
|
42
|
+
# {},
|
43
|
+
# params: {
|
44
|
+
# customer_id: "cust-15507323535c6e4c416c697",
|
45
|
+
# id: "en-deal-15499589715c627f3b57837",
|
46
|
+
# },
|
47
|
+
# )
|
48
|
+
#
|
49
|
+
# def self.redemptions(*args)
|
50
|
+
# options = {:refund => args[0]}
|
51
|
+
# params = options.merge(args[1][:params]) if args[1] && args[1][:params]
|
52
|
+
# self.prefix = "/customers/#{params[:customer_id]}/"
|
53
|
+
# resource = post("#{params[:id]}/redemptions", {}, options.to_json)
|
54
|
+
# instantiate_record(format.decode(resource.body), {})
|
55
|
+
# end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module VaucharAPI
|
2
|
+
# ==== Examples
|
3
|
+
# [Create]
|
4
|
+
# new_deal = VaucharAPI::Deal.new({
|
5
|
+
# title: "max_test",
|
6
|
+
# brand_id: "brn-15507182295c6e1515a956a",
|
7
|
+
# voucher_data: {
|
8
|
+
# value: "30",
|
9
|
+
# value_unit: "value",
|
10
|
+
# currency: "USD",
|
11
|
+
# expiry_time_type: "relative",
|
12
|
+
# expiry_time: "10",
|
13
|
+
# expiry_time_unit: "hours",
|
14
|
+
# },
|
15
|
+
# })
|
16
|
+
# new_deal.save
|
17
|
+
#
|
18
|
+
# [Read]
|
19
|
+
# deal = VaucharAPI::Deal.find("en-deal-15499589715c627f3b57837")
|
20
|
+
# deals = VaucharAPI::Deal.all
|
21
|
+
#
|
22
|
+
# [Delete]
|
23
|
+
# deal = VaucharAPI::Deal.find("en-deal-15499589715c627f3b57837")
|
24
|
+
# deal.destroy
|
25
|
+
#
|
26
|
+
# [Find By Brand]
|
27
|
+
# deals = VaucharAPI::Deal.find(:all, params: {brand_id: "brn-15507182295c6e1515a956a"})
|
28
|
+
|
29
|
+
class Deal < Base
|
30
|
+
self.prefix = "/engage/"
|
31
|
+
|
32
|
+
# def accepts_attributes
|
33
|
+
# [:name, :email]
|
34
|
+
# end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module VaucharAPI
|
2
|
+
# ==== Examples
|
3
|
+
# [Create]
|
4
|
+
# new_list = VaucharAPI::List.new(name: "max list", brand_id: "brn-15507182295c6e1515a956a")
|
5
|
+
# new_list.save
|
6
|
+
#
|
7
|
+
# [Read]
|
8
|
+
# list = VaucharAPI::List.find("list-15508273755c6fbf6fc8ac7")
|
9
|
+
# lists = VaucharAPI::List.all
|
10
|
+
#
|
11
|
+
# [Update]
|
12
|
+
# list = VaucharAPI::List.find("list-15508273755c6fbf6fc8ac7")
|
13
|
+
# list.name = "Max update"
|
14
|
+
# list.save
|
15
|
+
#
|
16
|
+
# [Delete]
|
17
|
+
# list = VaucharAPI::List.find("list-15508273755c6fbf6fc8ac7")
|
18
|
+
# list.destroy
|
19
|
+
#
|
20
|
+
# [Customers]
|
21
|
+
# list = VaucharAPI::List.find("list-15502036875c663b27600fe")
|
22
|
+
# list.get(:customers);
|
23
|
+
#
|
24
|
+
# [Add Customers]
|
25
|
+
# list = VaucharAPI::List.find("list-15502036875c663b27600fe")
|
26
|
+
# list.post(:customers, {}, {customers: ["cust-15508280955c6fc23f7f807", "cust-15507323535c6e4c416c697"]}.to_json)
|
27
|
+
#
|
28
|
+
# [Delete Customers]
|
29
|
+
# list = VaucharAPI::List.find("list-15502036875c663b27600fe")
|
30
|
+
# list.delete(:customers, {}, {customers: ["cust-15508280955c6fc23f7f807", "cust-15507323535c6e4c416c697"]})
|
31
|
+
#
|
32
|
+
# [Find By Brand]
|
33
|
+
# lists = VaucharAPI::List.find(:all, params: {brand_id: "brn-15507182295c6e1515a956a"})
|
34
|
+
|
35
|
+
class List < Base
|
36
|
+
self.prefix = "/engage/"
|
37
|
+
|
38
|
+
def accepts_attributes
|
39
|
+
[:name, :brand_id]
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/vauchar_api.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require "http_logger"
|
2
|
+
require "vauchar_api/configuration"
|
3
|
+
require "vauchar_api/version"
|
4
|
+
|
5
|
+
require "active_resource"
|
6
|
+
require "active_resource/formats_ext"
|
7
|
+
|
8
|
+
HttpLogger.log_request_body = true
|
9
|
+
|
10
|
+
module VaucharAPI
|
11
|
+
def self.config
|
12
|
+
yield Configuration
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
require "vauchar_api/resources"
|
17
|
+
require "vauchar_api/connection"
|
18
|
+
require "active_resource/connection_ext"
|
19
|
+
require "active_resource/custom_methods_ext"
|
data/vauchar_api.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "vauchar_api/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vauchar_api"
|
8
|
+
spec.version = VaucharAPI::VERSION
|
9
|
+
spec.authors = ["Max"]
|
10
|
+
spec.email = ["max.liu0325@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Write a short summary, because RubyGems requires one.}
|
13
|
+
spec.description = %q{Write a longer description or delete this line.}
|
14
|
+
# spec.homepage = "https://rubygems.org/gems/example"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Specify which files should be added to the gem when it is released.
|
18
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
19
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
20
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
end
|
22
|
+
spec.bindir = "exe"
|
23
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vauchar_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Max
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Write a longer description or delete this line.
|
56
|
+
email:
|
57
|
+
- max.liu0325@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".rspec"
|
64
|
+
- ".travis.yml"
|
65
|
+
- Gemfile
|
66
|
+
- Gemfile.lock
|
67
|
+
- LICENSE.txt
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- lib/active_resource/connection_ext.rb
|
73
|
+
- lib/active_resource/custom_methods_ext.rb
|
74
|
+
- lib/active_resource/formats_ext.rb
|
75
|
+
- lib/vauchar_api.rb
|
76
|
+
- lib/vauchar_api/configuration.rb
|
77
|
+
- lib/vauchar_api/connection.rb
|
78
|
+
- lib/vauchar_api/resources.rb
|
79
|
+
- lib/vauchar_api/resources/base.rb
|
80
|
+
- lib/vauchar_api/resources/brand.rb
|
81
|
+
- lib/vauchar_api/resources/customer.rb
|
82
|
+
- lib/vauchar_api/resources/customer_deal.rb
|
83
|
+
- lib/vauchar_api/resources/deal.rb
|
84
|
+
- lib/vauchar_api/resources/list.rb
|
85
|
+
- lib/vauchar_api/resources/verify_credentials.rb
|
86
|
+
- lib/vauchar_api/version.rb
|
87
|
+
- vauchar_api.gemspec
|
88
|
+
homepage:
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.7.6
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: Write a short summary, because RubyGems requires one.
|
112
|
+
test_files: []
|