Module: Billogram::Endpoint::ClassMethods
- Defined in:
- lib/billogram/endpoint.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #create(attributes) ⇒ Object
- #endpoint(value = nil) ⇒ Object
- #fetch(id = nil) ⇒ Object
- #perform_request(type, url, params = {}) ⇒ Object
- #search(options = {}) ⇒ Object
Instance Attribute Details
#default_search_options ⇒ Object
23 24 25 |
# File 'lib/billogram/endpoint.rb', line 23 def @default_search_options ||= { page: 1, page_size: 50 } end |
Instance Method Details
#create(attributes) ⇒ Object
41 42 43 |
# File 'lib/billogram/endpoint.rb', line 41 def create(attributes) perform_request(:post, endpoint.to_s, attributes) end |
#endpoint(value = nil) ⇒ Object
27 28 29 30 |
# File 'lib/billogram/endpoint.rb', line 27 def endpoint(value = nil) @endpoint = value if value @endpoint || name.demodulize.underscore end |
#fetch(id = nil) ⇒ Object
37 38 39 |
# File 'lib/billogram/endpoint.rb', line 37 def fetch(id = nil) perform_request(:get, "#{endpoint}/#{id}") end |
#perform_request(type, url, params = {}) ⇒ Object
45 46 47 48 |
# File 'lib/billogram/endpoint.rb', line 45 def perform_request(type, url, params = {}) response = Request.new(type, url, params).execute build_objects(response) end |
#search(options = {}) ⇒ Object
32 33 34 35 |
# File 'lib/billogram/endpoint.rb', line 32 def search( = {}) query = .merge() perform_request(:get, endpoint.to_s, query) end |