Class: Kintone::Client
- Inherits:
-
Object
- Object
- Kintone::Client
- Defined in:
- lib/kintone/client/client.rb,
lib/kintone/client/version.rb
Defined Under Namespace
Modules: Middleware Classes: Path
Constant Summary collapse
- ENDPOINT =
'https://%s.cybozu.com'- VERSION =
'0.1.4'
Instance Method Summary collapse
-
#initialize(options) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(options) ⇒ Client
Returns a new instance of Client.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kintone/client/client.rb', line 4 def initialize() @auth = {} if [:api_token] @auth[:api_token] = .delete(:api_token) else [:login_name, :password].each do |k| @auth[k] = .fetch(k) .delete(k) end end unless [:url] [:url] = ENDPOINT % .fetch(:subdomain) .delete(:subdomain) end @conn = Faraday.new() do |faraday| faraday.request :url_encoded faraday.request :record, :content_type => /\bjson$/ faraday.response :form, :content_type => /\bjson$/ # must set before :json faraday.response :json, :content_type => /\bjson$/ yield(faraday) if block_given? required_adapters = [Faraday::Adapter::NetHttp, Faraday::Adapter::Test] unless required_adapters.any? {|i| faraday.builder.handlers.include?(i) } faraday.adapter Faraday.default_adapter end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object (private)
39 40 41 42 43 44 45 |
# File 'lib/kintone/client/client.rb', line 39 def method_missing(method_name, *args) unless args.length.zero? raise ArgumentError, "wrong number of arguments (#{args.length} for 0)" end Path.new(@conn, @auth, method_name.to_s) end |