2016-09-19 88 views
1

我正在使用DocuSign REST API的docusign_rest gem,以下是我的DocuSign配置。Docusign與rails 4的集成

# config/initializers/docusign_rest.rb 

require 'docusign_rest' 
DocusignRest.configure do |config| 
    config.username  = '[email protected]' 
    config.password  = 'MyPassword' 
    config.integrator_key = 'My-key' 
    config.account_id  = 'account_id' 
    config.endpoint  = 'https://www.docusign.net/restapi' 
    config.api_version = 'v1' 
end 

當我嘗試連接並獲取account_id時,我得到nil作爲響應。

client = DocusignRest::Client.new 
puts client.get_account_id   # Returns nil. 

我使用rails-4.1.4ruby-2.2.2

我錯過了什麼?請建議。

+1

你試過'config.api_version ='v2''嗎? – DiegoSalazar

回答

1

不知道你是否明白這一點或不完全。這是另一個解決方案,使用httparty並不困難。如果你想創建例如模板的文檔,你的要求看起來可能是這樣:

baseUrl = "https://demo.docusign.net/restapi/v2/accounts/acct_number/envelopes" 
    @lease = Lease.find(lease.id) 
    @unit = @lease.unit 
    @application = @lease.application 
    @manager = @lease.property_manager 

    @application.applicants.each do |renter| 
    req = HTTParty.post(baseUrl, 
     body: { 
      "emailSubject": "DocuSign API call - Request Signature - Boom", 
      "templateId": "id of your template", 
      "templateRoles": [{ 
       "name": "#{renter.background.legal_name}", 
       "email": "#{renter.email}", 
       "recipientId": "1", 
       "roleName": "Lessee", 
       "tabs": { 
        "texttabs": [{ 
           "tablabel": "Rent", 
           "value": "#{@lease.rent}" 
           },{ 
           "tablabel": "Address", 
           "value": "987 apple lane" 
         }] 
        } 
       },{ 
       "email": "#{@manager.email}", 
       "name": "#{@manager.name}", 
       "roleName": "Lessor", 
       "tabs": { 
        "texttabs": [{ 
           "tablabel": "Any", 
           "value": "#{@lease.labels}" 
           },{ 
           "tablabel": "Address", 
           "value": "987 hoser lane" 
        }] 
       } 
      }], 
      "status": "sent" 
     }.to_json, 
     headers: { 
      "Content-Type" => "application/json", 
      'Accept' => 'application/json', 
      'X-DocuSign-Authentication' => '{ 
      "Username" : "place your", 
      "Password" : "credentials", 
      "IntegratorKey" : "here" 
      }' 
     }, :debug_output => $stdout) 

最終線調試輸出是讓你調試API請求,其可以在去除任何時候。

1

這是docusign_rest 0.1.1中的一個bug;該方法總是返回nil。該錯誤已被fixed和最新的寶石版本包括該修復程序。