Jump to content


  • Content Count

  • Joined

  • Last visited

  • Days Won


IElite last won the day on December 18 2018

IElite had the most liked content!

About IElite

  • Rank

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Interests
    FreePascal, Delphi, Smart Mobile Studio


  • Company name
    Cold River Labs
  • Sector
    Information technology
  • Position

Smart Mobile Studio

  • Edition

Recent Profile Visitors

4,113 profile views
  1. IElite

    How to resize a modal dialog

    Try capturing the orientation change explicitly and then calling the modal forms resize event within it function window: variant; external 'window' property; procedure TModalForm.InitializeObject; begin inherited;  {$I 'ModlForm:impl'} window.addEventListener('devicemotion', @Resize, false);  end;  procedure TModalForm.Resize; begin inherited; // your resize code here end;
  2. IElite

    Wrapping javascript library or ASM blocks ?

    oh shoot, i dont know why, but it is working now...hmmmm Thanks for all your help @lynkfs
  3. IElite

    Wrapping javascript library or ASM blocks ?

    Seems like what i posted in my last post, works as well...i.e., using my api unit The issue was with the first section of code and the token I guess I assumed you had to login first, and get the token, and then use the token to get the Client object ???? like this: var loginClient = new JSONRpcClient({ 'url': 'https://user-api.simplybook.me' + '/login', 'onerror': function (error) {}, }); var token = loginClient.getToken('ACME', '88e24ae6c5cb30d9205ffc05b.........d189fefc8d09eb64752d5433994d0'); is that not correct? It looks like you hardcoded the token ? i was assigning that token variable instead like @client = new JSONRpcClient({ 'url': '//user-api.simplybook.me', 'headers': { 'X-Company-Login': 'Acme', 'X-Token': token }, 'onerror': function (error) { alert(error); } });
  4. IElite

    Wrapping javascript library or ASM blocks ?

    hmm, ok i will give your code a try. I added theose to javascript files to my project and then added them to a unit called api unit api; interface {$R "jquery-3.3.1.js"} {$R "json-rpc-client.js"} and then included the api unit in my main form
  5. IElite

    Wrapping javascript library or ASM blocks ?

    Thanks, You can look at their API explorer page, which lets you walk through the steps live https://simplybook.me/api/developer-api/tab/explorer_api
  6. IElite

    Wrapping javascript library or ASM blocks ?

    I see to still be having trouble with that last line var EventList: variant := client.getEventList(-params-); in their example online, you do not have to pass params, they are optional var client = new JSONRpcClient({ 'url': '//user-api.simplybook.me', 'headers': { 'X-Company-Login': '{companyLogin}', 'X-Token': '{token}' }, 'onerror': function (error) { alert(error); } }); var events = client.getEventList(); I have this code outside my asm block writeln('ok'); var EventList: variant := client.getEventList(); writeln('ok'); the first OK is written, but the second is not The EventList should be filled with a large block of JSON e.g. { "1": { "id": "1", "name": "Часовая фотосесcия", "duration": "60", "buffertime_before": "0", "buffertime_after": "0", "hide_duration": "0", "description": "Если Вы хотите попробовать себя в роли модели, но не определились с образом. 10 отретушированных и готовых к печати фотографий + отснятый материал на диске", "picture": "03661dd2903a3b3707807e30676821ae.jpg", "is_public": "1", "is_active": "1", "position": "0", "file_id": "1", "seo_url": null, "is_recurring": "0", "picture_sub_path": "/image_files", "is_visible": "1", "picture_path": "/uploads/mib/image_files/preview/03661dd2903a3b3707807e30676821ae.jpg", "unit_map": { "1": null }, "classes_plugin_info": { "unit_group_binded_in_class": null, "unit_groups_binded_in_classes": [] } }, ...................................................................................... } }
  7. I am trying to use the API of the following website The API uses JSON-RPC 2.0 protocol. The API documentation is here They also provide a javascript library If I utilize this library in my SMS project, I can make the calls and get it to work, utlizing ASM block asm var loginClient = new JSONRpcClient({ 'url': 'https://user-api.simplybook.me' + '/login', 'onerror': function (error) {}, }); var token = loginClient.getToken('ACME', '88e24ae6c5cb30d9205ffc05b490daef8ddd189fefc'); var client = new JSONRpcClient({ 'url': '//user-api.simplybook.me', 'headers': { 'X-Company-Login': 'ACME', 'X-Token': token }, 'onerror': function (error) { alert(error); } }); console.log(JSON.stringify(client)); end; However, I am wondering if it is possible to create a Smart Pascal wrapper for this unit, so that I can call these in pascal and not have to worry about jumping back and forth between ASM block and pascal blocks of code? If so, can some one provide me an example of one of these? Are these two the only thing needing wrapper for? var JSONRpcClientException = function (code, message) { this.code = code; this.message = message; } var JSONRpcClient = function (options) { this.setOptions(options); this.init(); } Thanks
  8. IElite

    Endpoints & Resources ?

    OH OK, Thanks for your help!
  9. IElite

    Endpoints & Resources ?

    @lynkfs thanks, I see how you showed how to parse the Url and handle each case. thanks! not sure I am understanding how data works? I am getting "Content: undefined" in my browser. Can you tell me how the data variant is used?
  10. IElite

    Endpoints & Resources ?

    How do i create an endpoint/resource and call one of the HTTP server functions/verbs (with the endpoint/resource)? I do not see anything in the featured demos that show this. When using JS/Node.js and using Express, I would normally do var express = require('express') var app = express() app.get('/api/programs', function (req, res) { // }); app.delete('/api/programs/:id', function (req, res) { // }); So, when I create a new SMART NodeJS project, where do I do declare the endpoint/resource? unit Unit1; interface uses System.Types, System.Types.Convert, System.Objects, System.Device.Storage, System.Streams, System.Reader, System.Writer, System.JSON, System.IOUtils, SmartNJ.System, SmartNJ.Device.Storage, SmartNJ.Application, SmartNJ.Server.Http; type TNodeProgram = class(TObject) private FServer: TNJHTTPServer; protected procedure HandleServerStarted(Sender: TObject); procedure HandleRequest(Sender: TObject; const Request: TNJHttpRequest; const Response: TNJHttpResponse); public procedure Execute; constructor Create; virtual; destructor Destroy; override; end; implementation constructor TNodeProgram.Create; begin inherited Create; FServer := TNJHTTPServer.Create; FServer.Port := 1881; FServer.OnAfterServerStarted := HandleServerStarted; FServer.OnRequest := HandleRequest; end; destructor TNodeProgram.Destroy; begin FServer.free; inherited; end; procedure TNodeProgram.Execute; begin // Start the server FServer.Start(); end; procedure TNodeProgram.HandleServerStarted(Sender: TObject); begin writelnF('Server listening on port %d', [FServer.port]); end; procedure TNodeProgram.HandleRequest(Sender: TObject; const Request: TNJHttpRequest; const Response: TNJHttpResponse); begin // Just end the request by sending the headers back as a string response.&End(request.Headers.ToString()); end; end.
  11. IElite

    Send an email ?

    Oh ok, so if I upload the project to my server, then it should work?
  12. IElite

    Send an email ?

    Not sure I follow you. So the code is not for Browser?
  13. IElite

    Send an email ?

    Sorry, I guess that was the wrong terminology to use. I haven't yet actually tried to send an email. All i have done was to add the all the code you provided above, particularly the smart enabled code. When I run my app , without sending the email, I get that error. I can't delete the scope line because it will complain - as I stated above. Not sure I can also delete the clientId ? Do you think?
  14. IElite

    Send an email ?

    @lynkfs I am trying your "smart" example out above However, it is crashing on this part of the code. If I comment out this entire bit of code, then everything else compiles and runs fine. gapi.client.init(class apiKey = '*****yAlr4k8Qkb8MpbjSbGBIi5h9067lZ4b5Cs'; discoveryDocs = ["https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest"]; clientId = '*****3111041-b3sfpthnis4ofc94d4qg9eo93q9rd7co.apps.googleusercontent.com'; scope = 'https://www.googleapis.com/auth/gmail.send'; end); I am getting this error: Uncaught #<Object> [line #103] Yes, the astrisks are there to mask my keys , i am using my full key and clientId if I comment out the ClientId and Scope, it will also compile and run without errors gapi.client.init(class apiKey = '*****yAlr4k8Qkb8MpbjSbGBIi5h9067lZ4b5Cs'; discoveryDocs = ["https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest"]; //clientId = '*****3111041-b3sfpthnis4ofc94d4qg9eo93q9rd7co.apps.googleusercontent.com'; //scope = 'https://www.googleapis.com/auth/gmail.send'; end); However, if I uncomment just the clientId out of those two, then i get this message: client_id and scope must both be provided to initialize OAuth. [line #71] so, then i uncomment the scope and again, i get the uncaught object error message
  15. IElite

    Node.JS Deprecation Warning

    Kinda figured, just making sure