ruby 这是将desk.com中的数据导出到CSV文件的非常基本的脚本。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby 这是将desk.com中的数据导出到CSV文件的非常基本的脚本。相关的知识,希望对你有一定的参考价值。

require 'desk_api'
require 'csv'

# Create the CSV files
cases        = CSV.open('./cases.csv', 'wb')
interactions = CSV.open('./interactions.csv', 'wb')

# Add the headers to the CSV files
cases << ['Case #', 'Subject', 'Description', 'Status']
interactions << ['Case #', 'Body', 'Created Date']

# Run through the cases and interactions assuming DeskApi has been configured globally
DeskApi.cases.all do |res|
  cases << [res.id, res.subject, res.description, res.status]
  res.replies.all do |reply|
    interactions << [res.id, reply.body, reply.created_at]
  end
end

以上是关于ruby 这是将desk.com中的数据导出到CSV文件的非常基本的脚本。的主要内容,如果未能解决你的问题,请参考以下文章