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.
Files changed (56) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +4 -0
  7. data/Gemfile.lock +41 -0
  8. data/LICENSE.txt +21 -0
  9. data/README.md +98 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +13 -0
  12. data/bin/setup +8 -0
  13. data/config/solano.yml +6 -0
  14. data/feathr.gemspec +30 -0
  15. data/lib/feathr.rb +56 -0
  16. data/lib/feathr/api/account.rb +9 -0
  17. data/lib/feathr/api/accounts.rb +11 -0
  18. data/lib/feathr/api/api_token_auth.rb +14 -0
  19. data/lib/feathr/api/api_token_refresh.rb +14 -0
  20. data/lib/feathr/api/api_token_verify.rb +14 -0
  21. data/lib/feathr/api/cashout.rb +9 -0
  22. data/lib/feathr/api/cashouts.rb +20 -0
  23. data/lib/feathr/api/contractor.rb +9 -0
  24. data/lib/feathr/api/contractors.rb +11 -0
  25. data/lib/feathr/api/feathr_endpoint.rb +102 -0
  26. data/lib/feathr/api/feathr_error.rb +15 -0
  27. data/lib/feathr/api/feathr_object.rb +37 -0
  28. data/lib/feathr/api/featured_platforms.rb +11 -0
  29. data/lib/feathr/api/healthz.rb +13 -0
  30. data/lib/feathr/api/income.rb +9 -0
  31. data/lib/feathr/api/income_request.rb +9 -0
  32. data/lib/feathr/api/income_requests.rb +14 -0
  33. data/lib/feathr/api/incomes.rb +11 -0
  34. data/lib/feathr/api/invoice.rb +9 -0
  35. data/lib/feathr/api/invoices.rb +11 -0
  36. data/lib/feathr/api/manager.rb +13 -0
  37. data/lib/feathr/api/managers.rb +12 -0
  38. data/lib/feathr/api/membership.rb +27 -0
  39. data/lib/feathr/api/membership_request.rb +9 -0
  40. data/lib/feathr/api/membership_requests.rb +14 -0
  41. data/lib/feathr/api/memberships.rb +11 -0
  42. data/lib/feathr/api/paypal_service.rb +0 -0
  43. data/lib/feathr/api/platform.rb +13 -0
  44. data/lib/feathr/api/platforms.rb +11 -0
  45. data/lib/feathr/api/public_platforms.rb +11 -0
  46. data/lib/feathr/api/rebate.rb +9 -0
  47. data/lib/feathr/api/rebates.rb +11 -0
  48. data/lib/feathr/api/receiveable.rb +9 -0
  49. data/lib/feathr/api/receiveables.rb +11 -0
  50. data/lib/feathr/api/reset_password.rb +14 -0
  51. data/lib/feathr/api/user.rb +11 -0
  52. data/lib/feathr/api/users.rb +19 -0
  53. data/lib/feathr/client.rb +146 -0
  54. data/lib/feathr/config.rb +39 -0
  55. data/lib/feathr/version.rb +3 -0
  56. 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,9 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class Cashout < Feathr::Api::FeathrObject
5
+ api_path 'cashouts'
6
+ end
7
+
8
+ end
9
+ 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,9 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class Contractor < Feathr::Api::FeathrObject
5
+ api_path 'contractors'
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class Contractors < Feathr::Api::FeathrEndpoint
5
+ api_path 'contractors'
6
+ feathr_object Feathr::Api::Contractor
7
+ feathr_endpoints :all, :find, :create, :update
8
+ end
9
+
10
+ end
11
+ 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,15 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class FeathrError
5
+
6
+ attr_accessor :status, :errors
7
+
8
+ def initialize(status:, errors:)
9
+ @status, @errors = status, errors
10
+ end
11
+
12
+ end
13
+
14
+ end
15
+ 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,11 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class FeaturedPlatforms < Feathr::Api::FeathrEndpoint
5
+ api_path 'featured_platforms'
6
+ feathr_object Feathr::Api::Platform
7
+ feathr_endpoints :all, :find
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class Healthz < Feathr::Api::FeathrEndpoint
5
+ api_path 'healthz'
6
+
7
+ def check
8
+ client.request(method: :get, path: api_path)
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class Income < Feathr::Api::FeathrObject
5
+ api_path 'income'
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class IncomeRequest < Feathr::Api::FeathrObject
5
+ api_path 'income_requests'
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class IncomeRequests < Feathr::Api::FeathrEndpoint
5
+ api_path 'income_requests'
6
+ feathr_object Feathr::Api::IncomeRequest
7
+ feathr_endpoints :all, :find, :create
8
+
9
+
10
+ # TODO: accept, deny
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class Incomes < Feathr::Api::FeathrEndpoint
5
+ api_path 'income'
6
+ feathr_object Feathr::Api::Income
7
+ feathr_endpoints :all, :create, :update, :find, :destroy
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class Invoice < Feathr::Api::FeathrObject
5
+ api_path 'invoices'
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class Invoices < Feathr::Api::FeathrEndpoint
5
+ api_path 'invoices'
6
+ feathr_object Feathr::Api::Invoice
7
+ feathr_endpoints :all, :find, :create
8
+ end
9
+
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class Manager < Feathr::Api::FeathrObject
5
+ api_path 'managers'
6
+
7
+ def platforms
8
+ Feathr::Api::Platforms.new(prepended_path: path)
9
+ end
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class Managers < Feathr::Api::FeathrEndpoint
5
+ api_path 'managers'
6
+
7
+ feathr_object Feathr::Api::Manager
8
+ feathr_endpoints :find
9
+ end
10
+
11
+ end
12
+ 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
@@ -0,0 +1,9 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class MembershipRequest < Feathr::Api::FeathrObject
5
+ api_path 'membership_requests'
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class MembershipRequests < Feathr::Api::FeathrEndpoint
5
+ api_path 'membership_requests'
6
+ feathr_object Feathr::Api::MembershipRequest
7
+ feathr_endpoints :all, :find
8
+
9
+
10
+ # TODO: accept, deny
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ module Feathr
2
+ module Api
3
+
4
+ class Memberships < Feathr::Api::FeathrEndpoint
5
+ api_path 'memberships'
6
+ feathr_object Feathr::Api::Membership
7
+ feathr_endpoints :find, :create, :all
8
+ end
9
+
10
+ end
11
+ end