mobicom_candy 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +13 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +35 -0
- data/LICENSE.txt +21 -0
- data/README.md +55 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/mobicom_candy/auth.rb +5 -0
- data/lib/mobicom_candy/client.rb +184 -0
- data/lib/mobicom_candy/entity.rb +55 -0
- data/lib/mobicom_candy/errors.rb +10 -0
- data/lib/mobicom_candy/params.rb +13 -0
- data/lib/mobicom_candy/version.rb +3 -0
- data/lib/mobicom_candy.rb +6 -0
- data/mobicom_candy.gemspec +34 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0c28ff011620eeeef6af49c7fd34ca187f48694b
|
4
|
+
data.tar.gz: 6e47b62fa21e37c9ac79d95569dce95a34cdd7b1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d4f0bc4a1f2339217444cb196c7c71b76a771f16dde1d9379fb25ba439c8382a98eade84400d16080cd52902265da0a70fc4c68fefe4483f127c52436ab5daac
|
7
|
+
data.tar.gz: 211192c35c9fce5d43a6440f49d14f72341c8a257756be1dc40fc386b85864ad26497069c5a54c440ec0db5b8f9ba8a231e21cfde28fe66899755f0f17e7a7f1
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.4.2
|
5
|
+
before_install: gem install bundler -v 1.16.0
|
6
|
+
deploy:
|
7
|
+
provider: rubygems
|
8
|
+
api_key:
|
9
|
+
secure: bjgz5qOp42L4FRyrECtYG9SMTNxlsU06TCz1G2OfOgESmTH0YeCqo3a2nQ3DaWhsYgHY2GWImL8T+X9JGdpaSSOvc0g39otb5bj7k5jlcatvu2NszkAQKEnKdJngA+XSJL+hgZVLXBg5Cn8oVIbLg2YUYwIqh8R8Qa900Tvz6FBwZOBBdvBwZSW0ASORHscoUJFLVkl+tbm108QXGTS09uscpsPfohB7xKI/KJoncFl7F5vl037NbOiSTeRUruBMKAUhKbJNKOWvu/L+XnKWI3CKW0JwFTsPTBPQpTNWDxhv7SUhqtFb85SeBSOHdi52I1pgvTSiNiWalJPKAhpe+t9UvXxczCXL9PMpPEi97gndbp3QP5oLGfrCELZxXpTcC0e8OZX2LIwtNHMdytsSEHEKB6EVBAs3F+lW1fnKfoqtc66A1073hDARmg2pOEYGu0AGk9eMfPKaWOr+I5IrDo+0J4+1/+c6UXIjCceMxrUUr/uoLT0e3iejzXY9qrdszE2LM4u4358gNthmE1BLHWJs/sf1k+Xi1In20o3mQGnfrPvfkyHUE6M8ZuFjWZDzF1jWQ/RP4G7RjK00UWVwrGrB/gY2O66x4Pc9gyoLbgtMOmpHg3mNJqM1Wps1wGIhcWJ8EZ2IpT5NwULbHG6YHryOtNTFegzCdZJTs2c3nFE=
|
10
|
+
gem: mobicom_candy
|
11
|
+
on:
|
12
|
+
tags: true
|
13
|
+
repo: ssxenon01/mobicom_candy
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at ssxenon01@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
mobicom_candy (0.1.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
rake (10.5.0)
|
11
|
+
rspec (3.7.0)
|
12
|
+
rspec-core (~> 3.7.0)
|
13
|
+
rspec-expectations (~> 3.7.0)
|
14
|
+
rspec-mocks (~> 3.7.0)
|
15
|
+
rspec-core (3.7.1)
|
16
|
+
rspec-support (~> 3.7.0)
|
17
|
+
rspec-expectations (3.7.0)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.7.0)
|
20
|
+
rspec-mocks (3.7.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.7.0)
|
23
|
+
rspec-support (3.7.1)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler (~> 1.16)
|
30
|
+
mobicom_candy!
|
31
|
+
rake (~> 10.0)
|
32
|
+
rspec (~> 3.0)
|
33
|
+
|
34
|
+
BUNDLED WITH
|
35
|
+
1.16.0
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Gundsambuu Natsagdorj
|
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,55 @@
|
|
1
|
+
# MobicomCandy
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/mobicom_candy.svg)](https://badge.fury.io/rb/mobicom_candy) [![Build Status](https://travis-ci.org/ssxenon01/mobicom_candy.svg?branch=master)](https://travis-ci.org/ssxenon01/mobicom_candy)
|
4
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/afbec1dd7a17291317f5/maintainability)](https://codeclimate.com/github/ssxenon01/most_ots/maintainability)
|
5
|
+
[![codebeat badge](https://codebeat.co/badges/653553fa-b988-47d6-bca5-3c292ecfddb1)](https://codebeat.co/projects/github-com-ssxenon01-mobicom_candy-master)
|
6
|
+
[![Inline docs](http://inch-ci.org/github/ssxenon01/mobicom_candy.svg?branch=master)](http://inch-ci.org/github/ssxenon01/mobicom_candy)
|
7
|
+
[![Dependency Status](https://beta.gemnasium.com/badges/github.com/ssxenon01/mobicom_candy.svg)](https://beta.gemnasium.com/projects/github.com/ssxenon01/mobicom_candy)
|
8
|
+
|
9
|
+
Candy нь нээлттэй эхийг дэмжсэн Монголын хамгийн анхны цахим мөнгөний систем бөгөөд та өөрийн ашигладаг болон хөгжүүлдэг борлуулалтын системээ хэзээ ч, хаанаас ч Candy цахим мөнгөний системтэй холбох боломжтой боллоо.
|
10
|
+
|
11
|
+
Таны борлуулалтын систем (Кассын програм, Онлайн шоп) Сandy-д нэгдсэнээр дараах зүйлсийг хийх боломжтой:
|
12
|
+
|
13
|
+
Candy – гээр худалдан авалт хийх, төлбөр төлөх (Онлайн шоп дээр сandy – гээр худалдан авалт хийхэд зөвхөн хэрэглэгчийн дугаар байхад л хангалттай.)
|
14
|
+
Хэрэглэгчдээ сandy – гээр урамшуулах
|
15
|
+
Candy – гээр хөнгөлөлттэй үнээр худалдаалах
|
16
|
+
Сайтын тухай
|
17
|
+
Энэхүү сайт нь Сandy – тэй өөрийн борлуулалтын системээ холбохыг хүссэн бизнес эрхлэгч, программ хангамж хөгжүүлэгч хэн бүхэнд зориулагдсан хамгийн хялбар хувилбар бөгөөд танд бие даан өөрийн системдээ Сandy – гээр интеграц хийх боломжийг олгох болно.
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
Add this line to your application's Gemfile:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem 'mobicom_candy'
|
25
|
+
```
|
26
|
+
|
27
|
+
And then execute:
|
28
|
+
|
29
|
+
$ bundle
|
30
|
+
|
31
|
+
Or install it yourself as:
|
32
|
+
|
33
|
+
$ gem install mobicom_candy
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
TODO: Write usage instructions here
|
38
|
+
|
39
|
+
## Development
|
40
|
+
|
41
|
+
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.
|
42
|
+
|
43
|
+
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).
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ssxenon01/mobicom_candy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
48
|
+
|
49
|
+
## License
|
50
|
+
|
51
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
52
|
+
|
53
|
+
## Code of Conduct
|
54
|
+
|
55
|
+
Everyone interacting in the MobicomCandy project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/mobicom_candy/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "mobicom_candy"
|
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,184 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module MobicomCandy
|
5
|
+
# API Client Wrapper
|
6
|
+
class Client
|
7
|
+
# @param [String] token
|
8
|
+
def initialize(token)
|
9
|
+
@token = token
|
10
|
+
@last_sent = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
# @param [Integer] limit
|
14
|
+
# @param [Integer] offset
|
15
|
+
# @return [MobicomCandy::Entity]
|
16
|
+
def transaction(limit = 10, offset = 0)
|
17
|
+
get('transaction', limit: limit, offset: offset)
|
18
|
+
end
|
19
|
+
|
20
|
+
# @param [String] customer_id
|
21
|
+
# @param [String] system
|
22
|
+
# @return [MobicomCandy::Entity]
|
23
|
+
def customer(customer_id, system)
|
24
|
+
post('customer', customer: customer_id, 'customer.system' => system)
|
25
|
+
end
|
26
|
+
|
27
|
+
# @param [String] customer_id
|
28
|
+
# @param [String] system
|
29
|
+
# @param [Decimal] amount
|
30
|
+
# @param [String] description
|
31
|
+
# @return [MobicomCandy::Entity]
|
32
|
+
def reward(customer_id, system, amount, description)
|
33
|
+
post('reward',
|
34
|
+
'customer' => {
|
35
|
+
value: customer_id,
|
36
|
+
system: system
|
37
|
+
},
|
38
|
+
amount: amount,
|
39
|
+
description: description
|
40
|
+
)
|
41
|
+
end
|
42
|
+
|
43
|
+
# @param [String] customer_id
|
44
|
+
# @param [String] system
|
45
|
+
# @param [Decimal] amount
|
46
|
+
# @param [String] description
|
47
|
+
# @param [String] sms_prefix
|
48
|
+
# @param [String] sms_suffix
|
49
|
+
# @param [String] product
|
50
|
+
# @param [String] product_type
|
51
|
+
# @return [MobicomCandy::Entity]
|
52
|
+
def sell(customer_id, system, amount, description: nil, sms_prefix: nil, sms_suffix: nil, product: nil, product_type: nil)
|
53
|
+
post('sell',
|
54
|
+
'customer' => {
|
55
|
+
value: customer_id,
|
56
|
+
system: system
|
57
|
+
},
|
58
|
+
amount: amount,
|
59
|
+
description: description,
|
60
|
+
smsPrefix: sms_prefix,
|
61
|
+
smsSuffix: sms_suffix,
|
62
|
+
product: product,
|
63
|
+
productType: product_type
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
# @param [String] customer_id
|
68
|
+
# @param [String] system
|
69
|
+
# @param [Decimal] amount
|
70
|
+
# @param [String] tancode
|
71
|
+
# @return [MobicomCandy::Entity]
|
72
|
+
def sell_confirm(customer_id, system, amount, tancode)
|
73
|
+
post('sellconfirm', 'customer.value' => customer_id, 'customer.system' => system, amount: amount, tancode: tancode)
|
74
|
+
end
|
75
|
+
|
76
|
+
# @param [String] customer_id
|
77
|
+
# @param [String] system
|
78
|
+
# @param [Decimal] amount
|
79
|
+
# @param [String] pin
|
80
|
+
# @param [String] description
|
81
|
+
# @param [String] sms_prefix
|
82
|
+
# @param [String] sms_suffix
|
83
|
+
# @param [String] product
|
84
|
+
# @param [String] product_type
|
85
|
+
# @return [MobicomCandy::Entity]
|
86
|
+
def sell_card(customer_id, system, amount, pin, description: nil, sms_prefix: nil, sms_suffix: nil, product: nil, product_type: nil)
|
87
|
+
post('sellcard',
|
88
|
+
'customer' => {
|
89
|
+
value: customer_id,
|
90
|
+
system: system
|
91
|
+
},
|
92
|
+
amount: amount,
|
93
|
+
pin: pin,
|
94
|
+
description: description,
|
95
|
+
smsPrefix: sms_prefix,
|
96
|
+
smsSuffix: sms_suffix,
|
97
|
+
product: product,
|
98
|
+
productType: product_type
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
# @param fn [String] API Endpoint
|
104
|
+
# @param [Hash] params
|
105
|
+
# @return [MobicomCandy::Entity]
|
106
|
+
def post(fn, params = {})
|
107
|
+
request("/resource/partner/v1/#{fn}", params: params, type: POST)
|
108
|
+
end
|
109
|
+
|
110
|
+
# @param fn [String] API Endpoint
|
111
|
+
# @param [Hash] params
|
112
|
+
# @return [MobicomCandy::Entity]
|
113
|
+
def get(fn, params = {})
|
114
|
+
request("/resource/partner/v1/#{fn}", params: params, type: GET)
|
115
|
+
end
|
116
|
+
|
117
|
+
# @param [String] path
|
118
|
+
# @param [Hash] params
|
119
|
+
# @param [Enum] type
|
120
|
+
# @param [Function] block
|
121
|
+
def request(path, params: nil, type: GET, &block)
|
122
|
+
sleep(1) if @last_sent && @last_sent > (Time.now - 1000)
|
123
|
+
@last_sent = Time.now
|
124
|
+
uri = URI('https://' + host + path)
|
125
|
+
unless type::REQUEST_HAS_BODY || params.nil? || params.empty?
|
126
|
+
uri.query = Params.encode(params)
|
127
|
+
end
|
128
|
+
message = type.new(uri.request_uri)
|
129
|
+
message['Content-Type'] = 'application/json'
|
130
|
+
if type::REQUEST_HAS_BODY
|
131
|
+
if json_body?
|
132
|
+
message.body = JSON.generate(params)
|
133
|
+
else
|
134
|
+
message.form_data = params
|
135
|
+
end
|
136
|
+
end
|
137
|
+
message['Authorization'] = "Bearer #{@token}"
|
138
|
+
http = Net::HTTP.new(uri.host, Net::HTTP.https_default_port)
|
139
|
+
http.use_ssl = true
|
140
|
+
response = http.request(message)
|
141
|
+
parse(response, &block)
|
142
|
+
end
|
143
|
+
|
144
|
+
GET = Net::HTTP::Get
|
145
|
+
POST = Net::HTTP::Post
|
146
|
+
|
147
|
+
def json_body?
|
148
|
+
true
|
149
|
+
end
|
150
|
+
|
151
|
+
def host
|
152
|
+
'api.candy.mn'
|
153
|
+
end
|
154
|
+
|
155
|
+
# @param [String] response
|
156
|
+
# @param [Object] block
|
157
|
+
def parse(response, &block)
|
158
|
+
case response
|
159
|
+
when Net::HTTPNoContent
|
160
|
+
:no_content
|
161
|
+
when Net::HTTPSuccess
|
162
|
+
parse_success(response, &block)
|
163
|
+
when Net::HTTPUnauthorized
|
164
|
+
raise AuthenticationError, "#{response.code} response with: #{response.body}"
|
165
|
+
when Net::HTTPClientError
|
166
|
+
raise ClientError, "#{response.code} response with: #{response.body}"
|
167
|
+
when Net::HTTPServerError
|
168
|
+
raise ServerError, "#{response.code} response with: #{response.body}"
|
169
|
+
else
|
170
|
+
raise Error, "#{response.code} response from #{host}"
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def parse_success(response)
|
175
|
+
if response['Content-Type'].split(';').first == 'application/json'
|
176
|
+
JSON.parse(response.body, object_class: MobicomCandy::Entity)
|
177
|
+
elsif block_given?
|
178
|
+
yield response
|
179
|
+
else
|
180
|
+
response.body
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module MobicomCandy
|
2
|
+
class Entity
|
3
|
+
def initialize(**kwargs)
|
4
|
+
@attributes = kwargs
|
5
|
+
end
|
6
|
+
|
7
|
+
def []=(key, value)
|
8
|
+
name = self.class.attribute_names[key]
|
9
|
+
|
10
|
+
@attributes[name] = value
|
11
|
+
end
|
12
|
+
|
13
|
+
def respond_to_missing?(name, include_private = false)
|
14
|
+
@attributes.key?(name) || super
|
15
|
+
end
|
16
|
+
|
17
|
+
def method_missing(name, *args)
|
18
|
+
return super unless @attributes.key?(name)
|
19
|
+
|
20
|
+
@attributes[name]
|
21
|
+
end
|
22
|
+
|
23
|
+
def ==(other)
|
24
|
+
other.class == self.class && other.attributes == @attributes
|
25
|
+
end
|
26
|
+
|
27
|
+
def to_h
|
28
|
+
@attributes
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_json(*a)
|
32
|
+
@attributes.to_json(*a)
|
33
|
+
end
|
34
|
+
|
35
|
+
attr_reader :attributes
|
36
|
+
|
37
|
+
protected :attributes
|
38
|
+
|
39
|
+
def self.attribute_names
|
40
|
+
@attribute_names ||= Hash.new do |hash, key|
|
41
|
+
hash[key] = attribute_name(key)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.attribute_name(key)
|
46
|
+
return key if key.is_a?(Symbol)
|
47
|
+
|
48
|
+
key.split(PATTERN).join(UNDERSCORE).downcase.to_sym
|
49
|
+
end
|
50
|
+
|
51
|
+
PATTERN = /[\-_]|(?<=\w)(?=[A-Z])/
|
52
|
+
|
53
|
+
UNDERSCORE = '_'.freeze
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
module MobicomCandy
|
4
|
+
class Params
|
5
|
+
def self.encode(params)
|
6
|
+
params.flat_map { |k, vs| Array(vs).map { |v| "#{escape(k)}=#{escape(v)}" } }.join('&')
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.escape(component)
|
10
|
+
CGI.escape(component.to_s)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'mobicom_candy/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'mobicom_candy'
|
7
|
+
spec.version = MobicomCandy::VERSION
|
8
|
+
spec.authors = ['Gundsambuu Natsagdorj']
|
9
|
+
spec.email = ['ssxenon01@gmail.com']
|
10
|
+
|
11
|
+
spec.summary = 'Mobicom Candy API wrapper'
|
12
|
+
spec.description = 'Candy нь нээлттэй эхийг дэмжсэн Монголын хамгийн анхны цахим мөнгөний систем бөгөөд та өөрийн ашигладаг болон хөгжүүлдэг борлуулалтын системээ хэзээ ч, хаанаас ч Candy цахим мөнгөний системтэй холбох боломжтой боллоо.'
|
13
|
+
spec.homepage = 'https://developer.candy.mn'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org/'
|
20
|
+
else
|
21
|
+
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
25
|
+
f.match(%r{^(test|spec|features)/})
|
26
|
+
end
|
27
|
+
spec.bindir = 'exe'
|
28
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
29
|
+
spec.require_paths = ['lib']
|
30
|
+
|
31
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
32
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mobicom_candy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gundsambuu Natsagdorj
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-04-05 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: Candy нь нээлттэй эхийг дэмжсэн Монголын хамгийн анхны цахим мөнгөний
|
56
|
+
систем бөгөөд та өөрийн ашигладаг болон хөгжүүлдэг борлуулалтын системээ хэзээ ч,
|
57
|
+
хаанаас ч Candy цахим мөнгөний системтэй холбох боломжтой боллоо.
|
58
|
+
email:
|
59
|
+
- ssxenon01@gmail.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- ".rspec"
|
66
|
+
- ".travis.yml"
|
67
|
+
- CODE_OF_CONDUCT.md
|
68
|
+
- Gemfile
|
69
|
+
- Gemfile.lock
|
70
|
+
- LICENSE.txt
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- bin/console
|
74
|
+
- bin/setup
|
75
|
+
- lib/mobicom_candy.rb
|
76
|
+
- lib/mobicom_candy/auth.rb
|
77
|
+
- lib/mobicom_candy/client.rb
|
78
|
+
- lib/mobicom_candy/entity.rb
|
79
|
+
- lib/mobicom_candy/errors.rb
|
80
|
+
- lib/mobicom_candy/params.rb
|
81
|
+
- lib/mobicom_candy/version.rb
|
82
|
+
- mobicom_candy.gemspec
|
83
|
+
homepage: https://developer.candy.mn
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata:
|
87
|
+
allowed_push_host: https://rubygems.org/
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.6.13
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Mobicom Candy API wrapper
|
108
|
+
test_files: []
|