feathr 0.1.0
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 +8 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +41 -0
- data/LICENSE.txt +21 -0
- data/README.md +98 -0
- data/Rakefile +6 -0
- data/bin/console +13 -0
- data/bin/setup +8 -0
- data/config/solano.yml +6 -0
- data/feathr.gemspec +30 -0
- data/lib/feathr.rb +56 -0
- data/lib/feathr/api/account.rb +9 -0
- data/lib/feathr/api/accounts.rb +11 -0
- data/lib/feathr/api/api_token_auth.rb +14 -0
- data/lib/feathr/api/api_token_refresh.rb +14 -0
- data/lib/feathr/api/api_token_verify.rb +14 -0
- data/lib/feathr/api/cashout.rb +9 -0
- data/lib/feathr/api/cashouts.rb +20 -0
- data/lib/feathr/api/contractor.rb +9 -0
- data/lib/feathr/api/contractors.rb +11 -0
- data/lib/feathr/api/feathr_endpoint.rb +102 -0
- data/lib/feathr/api/feathr_error.rb +15 -0
- data/lib/feathr/api/feathr_object.rb +37 -0
- data/lib/feathr/api/featured_platforms.rb +11 -0
- data/lib/feathr/api/healthz.rb +13 -0
- data/lib/feathr/api/income.rb +9 -0
- data/lib/feathr/api/income_request.rb +9 -0
- data/lib/feathr/api/income_requests.rb +14 -0
- data/lib/feathr/api/incomes.rb +11 -0
- data/lib/feathr/api/invoice.rb +9 -0
- data/lib/feathr/api/invoices.rb +11 -0
- data/lib/feathr/api/manager.rb +13 -0
- data/lib/feathr/api/managers.rb +12 -0
- data/lib/feathr/api/membership.rb +27 -0
- data/lib/feathr/api/membership_request.rb +9 -0
- data/lib/feathr/api/membership_requests.rb +14 -0
- data/lib/feathr/api/memberships.rb +11 -0
- data/lib/feathr/api/paypal_service.rb +0 -0
- data/lib/feathr/api/platform.rb +13 -0
- data/lib/feathr/api/platforms.rb +11 -0
- data/lib/feathr/api/public_platforms.rb +11 -0
- data/lib/feathr/api/rebate.rb +9 -0
- data/lib/feathr/api/rebates.rb +11 -0
- data/lib/feathr/api/receiveable.rb +9 -0
- data/lib/feathr/api/receiveables.rb +11 -0
- data/lib/feathr/api/reset_password.rb +14 -0
- data/lib/feathr/api/user.rb +11 -0
- data/lib/feathr/api/users.rb +19 -0
- data/lib/feathr/client.rb +146 -0
- data/lib/feathr/config.rb +39 -0
- data/lib/feathr/version.rb +3 -0
- metadata +168 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
module Feathr
|
2
|
+
module Api
|
3
|
+
|
4
|
+
class ApiTokenRefresh < Feathr::Api::FeathrEndpoint
|
5
|
+
api_path 'api-token-refresh'
|
6
|
+
|
7
|
+
def refresh!(token)
|
8
|
+
query = { token: token }
|
9
|
+
client.request(method: :post, path: api_path, query: query)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Feathr
|
2
|
+
module Api
|
3
|
+
|
4
|
+
class ApiTokenVerify < Feathr::Api::FeathrEndpoint
|
5
|
+
api_path 'api-token-verify'
|
6
|
+
|
7
|
+
def verify(token)
|
8
|
+
query = { token: token }
|
9
|
+
client.request(method: :post, path: api_path, query: query)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Feathr
|
2
|
+
module Api
|
3
|
+
|
4
|
+
class Cashouts < Feathr::Api::FeathrEndpoint
|
5
|
+
api_path 'cashouts'
|
6
|
+
feathr_object Feathr::Api::Cashout
|
7
|
+
feathr_endpoints :find, :all, :create
|
8
|
+
|
9
|
+
def available
|
10
|
+
client.request(method: :get, path: api_path)
|
11
|
+
end
|
12
|
+
|
13
|
+
def fees(amount)
|
14
|
+
query = { amount: amount }
|
15
|
+
client.request(method: :post, path: api_path, query: query)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module Feathr
|
2
|
+
module Api
|
3
|
+
|
4
|
+
class FeathrEndpoint
|
5
|
+
attr_accessor :client, :prepended_path
|
6
|
+
|
7
|
+
def initialize(client: Feathr::Client.default, prepended_path: '')
|
8
|
+
@client = client
|
9
|
+
@prepended_path = prepended_path
|
10
|
+
end
|
11
|
+
|
12
|
+
class << self
|
13
|
+
def api_path(path)
|
14
|
+
define_method(:api_path) do
|
15
|
+
[
|
16
|
+
prepended_path,
|
17
|
+
path.gsub(/\/?$/, '/')
|
18
|
+
].join('/').gsub(/^\//,'')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def feathr_object(klass)
|
23
|
+
define_method(:feathr_object) do
|
24
|
+
klass
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def feathr_endpoints(*endpoints)
|
29
|
+
endpoints.each do |name|
|
30
|
+
self.send("define_#{ name }")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def define_all
|
35
|
+
define_method(:all) do
|
36
|
+
client.request(method: :get, path: api_path) do |data|
|
37
|
+
data.map do |resource|
|
38
|
+
if feathr_object == Feathr::Api::Membership
|
39
|
+
feathr_object.new(resource)
|
40
|
+
else
|
41
|
+
id = resource["url"][/\/(\d*)\/$/, 1]
|
42
|
+
feathr_object.new(resource, id)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def define_find
|
50
|
+
define_method(:find) do |id|
|
51
|
+
path = "#{ api_path }#{ id }/"
|
52
|
+
client.request(method: :get, path: path) do |data|
|
53
|
+
if feathr_object == Feathr::Api::Membership
|
54
|
+
feathr_object.new(data)
|
55
|
+
else
|
56
|
+
feathr_object.new(data, id)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def define_create
|
63
|
+
define_method(:create) do |query|
|
64
|
+
client.request(method: :post, path: api_path, query: query) do |data|
|
65
|
+
if feathr_object == Feathr::Api::Membership
|
66
|
+
feathr_object.new(data)
|
67
|
+
else
|
68
|
+
id = data["url"][/\/(\d*)\/$/, 1]
|
69
|
+
feathr_object.new(data, id)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def define_update
|
76
|
+
define_method(:update) do |id, query|
|
77
|
+
path = "#{ api_path }#{ id }/"
|
78
|
+
client.request(method: :patch, path: path, query: query) do |data|
|
79
|
+
if feathr_object == Feathr::Api::Membership
|
80
|
+
feathr_object.new(data)
|
81
|
+
else
|
82
|
+
id = data["url"][/\/(\d*)\/$/, 1]
|
83
|
+
feathr_object.new(data, id)
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def define_destroy
|
91
|
+
define_method(:destroy) do |id|
|
92
|
+
path = "#{ api_path }#{ id }/"
|
93
|
+
client.request(method: :delete, path: path) do |data|
|
94
|
+
data
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Feathr
|
2
|
+
module Api
|
3
|
+
|
4
|
+
class FeathrObject < Feathr::Api::FeathrEndpoint
|
5
|
+
attr_accessor :data, :id
|
6
|
+
|
7
|
+
api_path ''
|
8
|
+
|
9
|
+
def initialize(data, id)
|
10
|
+
@data = data
|
11
|
+
@id = id
|
12
|
+
end
|
13
|
+
|
14
|
+
def path
|
15
|
+
[api_path, id].join('')
|
16
|
+
end
|
17
|
+
|
18
|
+
def as_json
|
19
|
+
data.to_h
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.nested(*resources)
|
23
|
+
resources.each do |resource|
|
24
|
+
define_method(resource) do
|
25
|
+
ivar = "@#{ resource }"
|
26
|
+
klass_name = resource.to_s.split('_').collect(&:capitalize).join
|
27
|
+
klass = Object.const_get("Feathr::Api::#{ klass_name }")
|
28
|
+
|
29
|
+
instance_variable_get(ivar) ||
|
30
|
+
instance_variable_set(ivar, klass.new(prepended_path: path))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Feathr
|
2
|
+
module Api
|
3
|
+
|
4
|
+
class Membership < Feathr::Api::FeathrObject
|
5
|
+
api_path 'memberships'
|
6
|
+
|
7
|
+
def initialize(data)
|
8
|
+
@data = data
|
9
|
+
end
|
10
|
+
|
11
|
+
def path
|
12
|
+
api_path
|
13
|
+
end
|
14
|
+
|
15
|
+
def user
|
16
|
+
id = data["user"][/\/(\d*)\/$/, 1]
|
17
|
+
Feathr::Api::Users.new.find(id)
|
18
|
+
end
|
19
|
+
|
20
|
+
def platform
|
21
|
+
id = data["platform"][/\/(\d*)\/$/, 1]
|
22
|
+
Feathr::Api::Platforms.new.find(id)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|