Class: MatrixSdk::ApplicationService
- Includes:
- Logging
- Defined in:
- lib/matrix_sdk/application_service.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#port ⇒ Object
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(hs_url, as_token:, hs_token:, default_routes: true, **params) ⇒ ApplicationService
constructor
A new instance of ApplicationService.
- #registration ⇒ Object
Methods included from Logging
Constructor Details
#initialize(hs_url, as_token:, hs_token:, default_routes: true, **params) ⇒ ApplicationService
Returns a new instance of ApplicationService.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/matrix_sdk/application_service.rb', line 12 def initialize(hs_url, as_token:, hs_token:, default_routes: true, **params) logger.warning 'This abstraction is still under HEAVY development, expect errors' params = { protocols: %i[AS CS] }.merge(params).merge(access_token: as_token) if hs_url.is_a? Api @api = hs_url params.each do |k, v| api.instance_variable_set("@#{k}", v) if api.instance_variable_defined? "@#{k}" end else @api = Api.new hs_url, params end @id = params.fetch(:id, MatrixSdk::Api::USER_AGENT) @port = params.fetch(:port, 8888) @url = params.fetch(:url, URI("http://localhost:#{@port}")) @as_token = as_token @hs_token = hs_token @method_map = {} if default_routes add_method(:GET, '/_matrix/app/v1/users/', %r{^/_matrix/app/v1/users/(?<user>[^/]+)$}, :do_get_user) add_method(:GET, '/_matrix/app/v1/rooms/', %r{^/_matrix/app/v1/rooms/(?<room>[^/]+)$}, :do_get_room) add_method(:GET, '/_matrix/app/v1/thirdparty/protocol/', %r{^/_matrix/app/v1/thirdparty/protocol/(?<protocol>[^/]+)$}, :do_get_3p_protocol_p) add_method(:GET, '/_matrix/app/v1/thirdparty/user/', %r{^/_matrix/app/v1/thirdparty/user/(?<protocol>[^/]+)$}, :do_get_3p_user_p) add_method(:GET, '/_matrix/app/v1/thirdparty/location/', %r{^/_matrix/app/v1/thirdparty/location/(?<protocol>[^/]+)$}, :do_get_3p_location_p) add_method(:GET, '/_matrix/app/v1/thirdparty/user', %r{^/_matrix/app/v1/thirdparty/user$}, :do_get_3p_user) add_method(:GET, '/_matrix/app/v1/thirdparty/location', %r{^/_matrix/app/v1/thirdparty/location$}, :do_get_3p_location) add_method(:PUT, '/_matrix/app/v1/transactions/', %r{^/_matrix/app/v1/transactions/(?<txn_id>[^/]+)$}, :do_put_transaction) if params.fetch(:legacy_routes, false) add_method(:GET, '/users/', %r{^/users/(?<user>[^/]+)$}, :do_get_user) add_method(:GET, '/rooms/', %r{^/rooms/(?<room>[^/]+)$}, :do_get_room) add_method(:GET, '/_matrix/app/unstable/thirdparty/protocol/', %r{^/_matrix/app/unstable/thirdparty/protocol/(?<protocol>[^/]+)$}, :do_get_3p_protocol_p) add_method(:GET, '/_matrix/app/unstable/thirdparty/user/', %r{^/_matrix/app/unstable/thirdparty/user/(?<protocol>[^/]+)$}, :do_get_3p_user_p) add_method(:GET, '/_matrix/app/unstable/thirdparty/location/', %r{^/_matrix/app/unstable/thirdparty/location/(?<protocol>[^/]+)$}, :do_get_3p_location_p) add_method(:GET, '/_matrix/app/unstable/thirdparty/user', %r{^/_matrix/app/unstable/thirdparty/user$}, :do_get_3p_user) add_method(:GET, '/_matrix/app/unstable/thirdparty/location', %r{^/_matrix/app/unstable/thirdparty/location$}, :do_get_3p_location) add_method(:PUT, '/transactions/', %r{^/transactions/(?<txn_id>[^/]+)$}, :do_put_transaction) end end start_server end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
6 7 8 |
# File 'lib/matrix_sdk/application_service.rb', line 6 def api @api end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/matrix_sdk/application_service.rb', line 6 def port @port end |
Instance Method Details
#registration ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/matrix_sdk/application_service.rb', line 62 def registration { id: @id, url: @url, as_token: @as_token, hs_token: @hs_token, sender_localpart: '', namespaces: { users: [], aliases: [], rooms: [] }, rate_limited: false, protocols: [] } end |