Class: WP::API::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty, Endpoints
Defined in:
lib/wp/api/client.rb

Constant Summary collapse

DIRECT_PARAMS =
%w(type context filter)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Endpoints

#page, #page_named, #pages, #post, #post_meta, #post_named, #posts

Constructor Details

#initialize(host:, scheme: 'http', user: nil, password: nil) ⇒ Client

Returns a new instance of Client.



15
16
17
18
19
20
21
22
# File 'lib/wp/api/client.rb', line 15

def initialize(host:, scheme: 'http', user: nil, password: nil)
  @scheme = scheme
  @host = host
  @user = user
  @password = password

  fail ':host is required' unless host.is_a?(String) && host.length > 0
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



11
12
13
# File 'lib/wp/api/client.rb', line 11

def host
  @host
end

Instance Method Details

#inspectObject



24
25
26
# File 'lib/wp/api/client.rb', line 24

def inspect
  to_s.sub(/>$/, '') + " @scheme=\"#{@scheme}\" @host=\"#{@host}\" @user=\"#{@user}\" @password=#{@password.present?}>"
end