Class: Bonita::Client
- Inherits:
-
Object
- Object
- Bonita::Client
- Defined in:
- lib/bonita/client.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#redirect_url ⇒ Object
readonly
Returns the value of attribute redirect_url.
-
#tenant ⇒ Object
readonly
Returns the value of attribute tenant.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #login ⇒ Object
- #logout ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
55 56 57 58 59 60 |
# File 'lib/bonita/client.rb', line 55 def initialize( = {}) @url = [:url] @username = [:username] @password = [:password] @tenant = [:tenant] end |
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
4 5 6 |
# File 'lib/bonita/client.rb', line 4 def password @password end |
#redirect_url ⇒ Object (readonly)
Returns the value of attribute redirect_url.
4 5 6 |
# File 'lib/bonita/client.rb', line 4 def redirect_url @redirect_url end |
#tenant ⇒ Object (readonly)
Returns the value of attribute tenant.
4 5 6 |
# File 'lib/bonita/client.rb', line 4 def tenant @tenant end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
4 5 6 |
# File 'lib/bonita/client.rb', line 4 def url @url end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
4 5 6 |
# File 'lib/bonita/client.rb', line 4 def username @username end |
Class Method Details
.resources ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/bonita/client.rb', line 7 def resources { customuserinfo: { definitions: Customuserinfo::DefinitionResource, users: Customuserinfo::UserResource, values: Customuserinfo::ValueResource, }, bpm: { processes: Bpm::ProcessResource, }, identity: { groups: Identity::GroupResource, memberships: Identity::MembershipResource, roles: Identity::RoleResource, users: Identity::UserResource, }, } end |
.start(options = {}) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/bonita/client.rb', line 26 def start( = {}) client = new() client.login yield(client) ensure client.logout end |
Instance Method Details
#connection ⇒ Object
81 82 83 84 85 86 87 88 89 |
# File 'lib/bonita/client.rb', line 81 def connection @faraday ||= Faraday.new do |conn| conn.use :cookie_jar conn.use Bonita::Middleware::CSRF conn.use Faraday::Request::UrlEncoded conn.adapter Faraday.default_adapter end end |
#login ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/bonita/client.rb', line 62 def login response = connection.post '/bonita/loginservice' do |req| req.headers['Content-Type'] = 'application/x-www-form-urlencoded' req.body = { username: @username, password: @password, tenant: @tenant, } end raise Bonita::AuthError, 'Unable to log in' if response.body.include?('Unable to log in') true end |
#logout ⇒ Object
77 78 79 |
# File 'lib/bonita/client.rb', line 77 def logout connection.get '/bonita/logoutservice?redirect=false' end |