Class: Xendify::Client
- Inherits:
-
Object
- Object
- Xendify::Client
- Defined in:
- lib/xendify/client.rb
Instance Method Summary collapse
- #get(url, params = nil) ⇒ Object
-
#initialize(authorization = nil, options = {}) ⇒ Client
constructor
A new instance of Client.
- #invoice ⇒ Object
- #post(url, params) ⇒ Object
Constructor Details
#initialize(authorization = nil, options = {}) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/xendify/client.rb', line 9 def initialize( = nil, = {}) @connection = Faraday.new(url: BASE_URL) do |connection| connection.request :basic_auth, , '' connection.request :json connection.response :json # logger = find_logger(options[:logger]) # if logger # connection.response :logger, logger, { headers: false, bodies: true } do |log| # filtered_logs = options[:filtered_logs] # if filtered_logs.respond_to?(:each) # filtered_logs.each do |filter| # log.filter(%r{(#{filter}=)([\w+-.?@:/]+)}, '\1[FILTERED]') # log.filter(%r{(#{filter}":")([\w+-.?@:/]+)}, '\1[FILTERED]') # log.filter(%r{(#{filter}":)([\w+-.?@:/]+)}, '\1[FILTERED]') # end # end # end # end connection.use Xendify::Middleware::HandleResponseException connection.adapter Faraday.default_adapter end end |
Instance Method Details
#get(url, params = nil) ⇒ Object
33 34 35 36 |
# File 'lib/xendify/client.rb', line 33 def get(url, params = nil) response = @connection.get(url, params) response.body end |
#invoice ⇒ Object
43 44 45 |
# File 'lib/xendify/client.rb', line 43 def invoice @invoice ||= Xendify::Invoice.new(self) end |
#post(url, params) ⇒ Object
38 39 40 41 |
# File 'lib/xendify/client.rb', line 38 def post(url, params) response = @connection.post(url, params) response.body end |