Гем для генерации mswallet файлов для приложения Кошелек на платформе WP8+.
Для установки добавьте в ваш Gemfile:
gem 'mswallet'
И выполните:
$ bundle
Или можете установить вручную:
$ gem install mswallet
Если вы хотиет поддерживать запросы на обновление карточек, вы можете добавить Rack::PassbookRack к вашим middleware. В Rails это будет выглядеть так:
config.middleware.use Rack::MswalletRack
По-умолчанию для обработки запросов используется класс Mswallet::Handler, но вы можете установить свой:
Mswallet.custom_rack_handler = MyCustomHandler
# или
Mswallet.configure do |m|
m.custom_rack_handler = MyCustomHandler
end
pass = Mswallet::Pass.new
pass['Kind'] = 'General'
pass['Id'] = '00001'
pass['DisplayName'] = 'Test wallet'
pass['IssuerDisplayName'] = 'Test wallet'
pass['HeaderColor'] = '#0000FF'
pass['BodyColor'] = '#FFFFFF'
properties = {}
properties['Header'] = {
'Property' => [
{
'Key' => 'Hd1',
'Name' => 'Header Text',
'Value' => 'Name'
},
{
'Key' => 'Hd2',
'Name' => 'Header Text2',
'Value' => nil #пустое значение:  
}
]
}
pass['DisplayProperties'] = properties
pass.add_file name: 'file1', content: 'fileContent1'
pass.add_file name: 'file2', content: 'fileContent2'
pass.add_locale 'ru-RU', { 'hello_world' => 'Привет мир' }
pass['WebServiceUrl'] = "http://localhost:3000/api"
pass['AuthenticationToken'] = 'secret_token'
mswallet = pass.file
send_file mswallet.path, type: 'application/vnd.ms.wallet', disposition: 'attachment', filename: "pass.mswallet"
# Или потоком
mswallet = pass.stream
send_data mswallet.string, type: 'application/vnd.ms.wallet', disposition: 'attachment', filename: "pass.mswallet"
- Fork it ( http://github.com/fuCtor/mswallet/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request