Class: MfCloud::Invoice::Client
- Inherits:
-
Object
- Object
- MfCloud::Invoice::Client
- Defined in:
- lib/mf_cloud/invoice/client.rb
Instance Method Summary collapse
- #billing_status_payment ⇒ Object
- #billings ⇒ Object
- #delete(path, params = {}) ⇒ Object
- #get(path, params = {}) ⇒ Object
-
#initialize(options = {}) {|@config| ... } ⇒ Client
constructor
A new instance of Client.
- #items ⇒ Object
- #office ⇒ Object
- #partners ⇒ Object
- #post(path, params = {}) ⇒ Object
- #put(path, params = {}) ⇒ Object
Constructor Details
#initialize(options = {}) {|@config| ... } ⇒ Client
Returns a new instance of Client.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/mf_cloud/invoice/client.rb', line 29 def initialize( = {}, &block) @config = MfCloud::Invoice::Configure.new() yield @config if block_given? @conn = Faraday.new(url: "#{MfCloud::Invoice::API_URL}#{@config.api_version}") do |faraday| faraday.request :json faraday.response :json faraday.adapter Faraday.default_adapter end end |
Instance Method Details
#billing_status_payment ⇒ Object
59 60 61 |
# File 'lib/mf_cloud/invoice/client.rb', line 59 def billing_status_payment @_billing_status_payment ||= MfCloud::Invoice::Api::BillingStatusPayment.new(self) end |
#billings ⇒ Object
55 56 57 |
# File 'lib/mf_cloud/invoice/client.rb', line 55 def billings @_billings ||= MfCloud::Invoice::Api::Billing.new(self) end |
#delete(path, params = {}) ⇒ Object
95 96 97 98 99 100 101 102 |
# File 'lib/mf_cloud/invoice/client.rb', line 95 def delete(path, params = {}) res = @conn.delete do |req| req.headers['Authorization'] = "Bearer #{@config.access_token}" req.url path, params end check_response!(res) end |
#get(path, params = {}) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/mf_cloud/invoice/client.rb', line 63 def get(path, params = {}) res = @conn.get do |req| req.headers['Authorization'] = "Bearer #{@config.access_token}" req.url path, params end check_response!(res) res.body end |
#items ⇒ Object
51 52 53 |
# File 'lib/mf_cloud/invoice/client.rb', line 51 def items @_items ||= MfCloud::Invoice::Api::Item.new(self) end |
#office ⇒ Object
43 44 45 |
# File 'lib/mf_cloud/invoice/client.rb', line 43 def office @_office ||= MfCloud::Invoice::Api::Office.new(self) end |
#partners ⇒ Object
47 48 49 |
# File 'lib/mf_cloud/invoice/client.rb', line 47 def partners @_partners ||= MfCloud::Invoice::Api::Partner.new(self) end |
#post(path, params = {}) ⇒ Object
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/mf_cloud/invoice/client.rb', line 73 def post(path, params = {}) res = @conn.post do |req| req.headers['Authorization'] = "Bearer #{@config.access_token}" req.url path req.body = params end check_response!(res) res.body end |
#put(path, params = {}) ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/mf_cloud/invoice/client.rb', line 84 def put(path, params = {}) res = @conn.put do |req| req.headers['Authorization'] = "Bearer #{@config.access_token}" req.url path req.body = params end check_response!(res) res.body end |